修改下载按钮文案显示逻辑,修改多版本显示顺序逻辑,更换引导图

This commit is contained in:
huangzhuanghua
2016-11-21 11:27:27 +08:00
parent 7c801366ef
commit 2a92c10777
6 changed files with 109 additions and 77 deletions

View File

@ -229,14 +229,20 @@ public abstract class DetailActivity extends BaseActivity implements View.OnClic
}
} else {
int doneCount = 0; // 下载完成数量
int pluginCount = 0; // 可插件化数量
int updateCount = 0; // 可更新数量
int installCount = 0; // 已安装数量
int pluginCount = 0; // 可插件化数量
DownloadEntity downloadEntity;
for (ApkEntity apkEntity : gameEntity.getApk()) {
downloadEntity = DownloadManager.getInstance(this).get(apkEntity.getUrl());
if (downloadEntity != null && downloadEntity.getStatus().equals(DownloadStatus.done)) {
doneCount++;
if (downloadEntity != null) {
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
doneCount++;
} else if (downloadEntity.isPluggable()) {
pluginCount++;
} else if (downloadEntity.isUpdate()) {
updateCount++;
}
}
if (PackageManager.isCanUpdate(gameEntity.getId(), apkEntity.getPackageName())) {
updateCount++;
@ -254,28 +260,24 @@ public abstract class DetailActivity extends BaseActivity implements View.OnClic
if (doneCount != 0) {
status = "安装";
detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_download_style);
} else if (pluginCount != 0) {
status = "插件化";
detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
} else if (updateCount != 0) {
status = "更新";
detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_download_style);
} else if (installCount != 0) {
status = "打开";
detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_launch_style);
} else if (pluginCount != 0) {
status = "插件化";
detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
} else {
status = "下载";
detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_download_style);
}
if (TextUtils.isEmpty(downloadAddWord)) {
detail_tv_download.setBackgroundResource(
R.drawable.game_item_btn_download_style);
detail_tv_download.setText(String.format(status + "《%s》",
gameEntity.getName()));
} else {
detail_tv_download.setBackgroundResource(
R.drawable.game_item_btn_download_style);
detail_tv_download.setText(String.format(status + "《%s》%s",
gameEntity.getName(), downloadAddWord));
}

View File

@ -166,31 +166,34 @@ public class DownloadItemUtils {
TextView download_speed,
TextView download_percentage,
TextView downloadBtn,
GameEntity entity,
GameEntity gameEntity,
boolean isShowPlatform) {
ArrayMap<String, DownloadEntity> entryMap = entity.getEntryMap();
ArrayMap<String, DownloadEntity> entryMap = gameEntity.getEntryMap();
// 更新下载按钮状态
int doneCount = 0; // 下载完成数量
int pluginCount = 0; // 可插件化数量
int updateCount = 0; // 可更新数量
int installCount = 0; // 已安装数量
int pluginCount = 0; // 可插件化数量
if (entryMap != null && !entryMap.isEmpty()) {
DownloadEntity downloadEntity;
for (String key : entryMap.keySet()) {
if (entryMap.get(key).getStatus().equals(DownloadStatus.done)) {
downloadEntity = entryMap.get(key);
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
doneCount++;
} else if (downloadEntity.isPluggable()) {
pluginCount++;
} else if (downloadEntity.isUpdate()) {
updateCount++;
}
}
}
for (ApkEntity apkEntity : entity.getApk()) {
if (PackageManager.isCanUpdate(entity.getId(), apkEntity.getPackageName())) {
for (ApkEntity apkEntity : gameEntity.getApk()) {
if (PackageManager.isCanUpdate(gameEntity.getId(), apkEntity.getPackageName())) {
updateCount++;
}
}
for (ApkEntity apkEntity : entity.getApk()) {
if (PackageManager.isInstalled(apkEntity.getPackageName())) {
if (!PackageUtils.isSignature(context, apkEntity.getPackageName())) {
pluginCount++;
@ -204,15 +207,15 @@ public class DownloadItemUtils {
if (doneCount != 0) {
downloadBtn.setText("安装");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
} else if (pluginCount != 0) {
downloadBtn.setText("插件化");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
} else if (updateCount != 0) {
downloadBtn.setText("更新");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
} else if (installCount != 0) {
downloadBtn.setText("打开");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_launch_style);
} else if (pluginCount != 0) {
downloadBtn.setText("插件化");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
} else {
downloadBtn.setText("下载");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
@ -222,7 +225,7 @@ public class DownloadItemUtils {
DownloadEntity downloadEntity;
LinkedBlockingQueue<String> queue = DownloadManager.getInstance(context).getQueue(entity.getName());
LinkedBlockingQueue<String> queue = DownloadManager.getInstance(context).getQueue(gameEntity.getName());
if (queue != null && !queue.isEmpty()) {
downloadEntity = entryMap.get(queue.peek());
} else {
@ -343,14 +346,10 @@ public class DownloadItemUtils {
boolean isShowPlatform) {
// 控制是否显示下载按钮
if (Config.isShow(context)) {
downloadBtn.setVisibility(View.VISIBLE);
if (!Config.isShow(context) || "光环助手".equals(entity.getName())) {
downloadBtn.setVisibility(View.GONE);
} else {
downloadBtn.setVisibility(View.GONE);
}
if ("光环助手".equals(entity.getName())) {
downloadBtn.setVisibility(View.GONE);
downloadBtn.setVisibility(View.VISIBLE);
}
if (entity.getApk() == null || entity.getApk().isEmpty()) {
@ -359,6 +358,7 @@ public class DownloadItemUtils {
game_ll_info.setVisibility(View.GONE);
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_style);
downloadBtn.setText("暂无");
downloadBtn.setClickable(false);
} else if (entity.getApk().size() == 1) {
updateNormalItem(context, textView, game_progressbar, game_ll_info, download_speed,
download_percentage, downloadBtn, entity, isShowPlatform);

View File

@ -276,49 +276,45 @@ public class DownloadDialog implements OnCollectionCallBackListener {
}
private ArrayList<ApkEntity> sortApk(List<ApkEntity> apkList) {
DownloadEntity downloadEntity;
List<ApkEntity> doneList = new ArrayList<>();
List<ApkEntity> updateList = new ArrayList<>();
List<ApkEntity> installedList = new ArrayList<>();
List<ApkEntity> pluginList = new ArrayList<>();
List<ApkEntity> downloadList = new ArrayList<>();
List<ApkEntity> noPicList = new ArrayList<>();
List<ApkEntity> pluginDoneList = new ArrayList<>(); // 安装插件
List<ApkEntity> pluginDownloadList = new ArrayList<>(); // 插件化下载中
List<ApkEntity> pluginList = new ArrayList<>(); // 插件化
List<ApkEntity> updateDoneList = new ArrayList<>(); // 安装更新
List<ApkEntity> updateDownloadList = new ArrayList<>(); // 更新下载中
List<ApkEntity> updateList = new ArrayList<>(); // 更新
List<ApkEntity> doneList = new ArrayList<>(); // 安装
List<ApkEntity> downloadList = new ArrayList<>(); // 下载中
List<ApkEntity> installList = new ArrayList<>(); // 启动
List<ApkEntity> noPicList = new ArrayList<>(); // 默认(无图片)
DownloadEntity downloadEntity;
String packageName;
Object gh_id;
for (int i = 0, size = apkList.size(); i < size; i++) {
String packageName = apkList.get(i).getPackageName();
Object gh_id = PackageUtils.getMetaData(context, packageName, "gh_id");
if (PackageManager.isInstalled(packageName)
&& (gh_id == null || gh_id.equals(gameEntity.getId()))) {
if (PackageManager.isCanUpdate(gameEntity.getId(), packageName)) {
updateList.add(apkList.remove(i));
size--;
i--;
} else if (!PackageUtils.isSignature(context, packageName)) {
pluginList.add(apkList.remove(i));
size--;
i--;
} else {
installedList.add(apkList.remove(i));
size--;
i--;
}
} else {
downloadEntity = DownloadManager.getInstance(context).get(apkList.get(i).getUrl());
if (downloadEntity != null) {
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
doneList.add(apkList.remove(i));
downloadEntity = DownloadManager.getInstance(context).get(apkList.get(i).getUrl());
packageName = apkList.get(i).getPackageName();
gh_id = PackageUtils.getMetaData(context, packageName, "gh_id");
if (downloadEntity == null) {
if (PackageManager.isInstalled(packageName)
&& (gh_id == null || gh_id.equals(gameEntity.getId()))) {
if (PackageManager.isCanUpdate(gameEntity.getId(), packageName)) {
updateList.add(apkList.remove(i));
size--;
i--;
} else if (!PackageUtils.isSignature(context, packageName)) {
pluginList.add(apkList.remove(i));
size--;
i--;
} else {
downloadList.add(apkList.remove(i));
installList.add(apkList.remove(i));
size--;
i--;
}
size--;
i--;
} else {
String platform = apkList.get(i).getPlatform();
int id = PlatformUtils.getInstance(context).getPlatformPic(
platform);
int id = PlatformUtils.getInstance(context).getPlatformPic(platform);
if (id == 0) {
String path = PlatformUtils.getInstance(context)
.getPlatformPicPath(platform);
String path = PlatformUtils.getInstance(context).getPlatformPicPath(platform);
if (path == null) {
noPicList.add(apkList.remove(i));
size--;
@ -326,14 +322,48 @@ public class DownloadDialog implements OnCollectionCallBackListener {
}
}
}
} else {
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
if (downloadEntity.isPluggable()) {
pluginDoneList.add(apkList.remove(i));
size--;
i--;
} else if (downloadEntity.isUpdate()) {
updateDoneList.add(apkList.remove(i));
size--;
i--;
} else {
doneList.add(apkList.remove(i));
size--;
i--;
}
} else {
if (downloadEntity.isPluggable()) {
pluginDownloadList.add(apkList.remove(i));
size--;
i--;
} else if (downloadEntity.isUpdate()) {
updateDownloadList.add(apkList.remove(i));
size--;
i--;
} else {
downloadList.add(apkList.remove(i));
size--;
i--;
}
}
}
}
ArrayList<ApkEntity> list = new ArrayList<>();
list.addAll(doneList);
list.addAll(updateList);
list.addAll(installedList);
list.addAll(pluginDoneList);
list.addAll(pluginDownloadList);
list.addAll(pluginList);
list.addAll(updateDoneList);
list.addAll(updateDownloadList);
list.addAll(updateList);
list.addAll(doneList);
list.addAll(downloadList);
list.addAll(installList);
list.addAll(apkList);
list.addAll(noPicList);
return list;

View File

@ -176,12 +176,12 @@ public class SearchGameDetailFragmentAdapter extends RecyclerView.Adapter<GameNo
}
});
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()
|| !Config.isShow(context)) {
if (!Config.isShow(context) || "光环助手".equals(gameEntity.getName())) {
viewHolder.downloadBtn.setVisibility(View.GONE);
} else if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
viewHolder.downloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_style);
viewHolder.downloadBtn.setText("暂无");
} else if ("光环助手".equals(gameEntity.getName())) {
viewHolder.downloadBtn.setVisibility(View.GONE);
viewHolder.downloadBtn.setClickable(false);
} else {
viewHolder.downloadBtn.setVisibility(View.VISIBLE);
viewHolder.downloadBtn.setOnClickListener(new OnClickListener() {

View File

@ -168,12 +168,12 @@ public class SearchGameListFragmentAdapter extends RecyclerView.Adapter<Recycler
}
});
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()
|| !Config.isShow(context) ) {
if (!Config.isShow(context) || "光环助手".equals(gameEntity.getName())) {
viewHolder.downloadBtn.setVisibility(View.GONE);
} else if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
viewHolder.downloadBtn.setBackgroundResource(R.drawable.game_item_btn_pause_style);
viewHolder.downloadBtn.setText("暂无");
} else if ("光环助手".equals(gameEntity.getName())) {
viewHolder.downloadBtn.setVisibility(View.GONE);
viewHolder.downloadBtn.setClickable(false);
} else {
viewHolder.downloadBtn.setVisibility(View.VISIBLE);
viewHolder.downloadBtn.setOnClickListener(new View.OnClickListener() {