整理hardcode问题,整理imageUtils工具类

This commit is contained in:
kehaoyuan
2017-10-19 09:11:22 +08:00
parent 3d7e994b93
commit 8d0ab82f15
51 changed files with 261 additions and 192 deletions

View File

@ -147,25 +147,25 @@ public class DownloadItemUtils {
final String packageName = apkEntity.getPackageName();
if (gameEntity.isPluggable()) {
holder.gameDownloadBtn.setText("插件化");
holder.gameDownloadBtn.setText(R.string.pluggable);
setwhat(context, holder, apkEntity, packageName);
} else if (PackageManager.isInstalled(packageName)) {
if (PackageManager.isCanUpdate(gameEntity.getId(), packageName)) {
holder.gameDownloadBtn.setText("更新");
holder.gameDownloadBtn.setText(R.string.update);
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
} else {
if (gameEntity.getTag() != null && gameEntity.getTag().size() != 0
&& !TextUtils.isEmpty(apkEntity.getGhVersion())
&& !PackageUtils.isSignature(context, packageName)) {
holder.gameDownloadBtn.setText("插件化");
holder.gameDownloadBtn.setText(R.string.pluggable);
setwhat(context, holder, apkEntity, packageName);
} else {
holder.gameDownloadBtn.setText("启动");
holder.gameDownloadBtn.setText(R.string.launch);
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_launch_style);
}
}
} else {
holder.gameDownloadBtn.setText("下载");
holder.gameDownloadBtn.setText(R.string.download);
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_download_style);
}
}
@ -244,7 +244,7 @@ public class DownloadItemUtils {
}
if (isNormal) {
holder.gameDownloadBtn.setText("下载中");
holder.gameDownloadBtn.setText(R.string.downloading);
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
holder.gameDownloadBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.text_downloading_style));
}
@ -258,7 +258,7 @@ public class DownloadItemUtils {
holder.gameDownloadPercentage.setText(downloadEntity.getPercent() + "%");
if (isNormal) {
holder.gameDownloadBtn.setText("下载中");
holder.gameDownloadBtn.setText(R.string.downloading);
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
holder.gameDownloadBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.text_downloading_style));
}
@ -274,7 +274,7 @@ public class DownloadItemUtils {
holder.gameDownloadPercentage.setText(downloadEntity.getPercent() + "%");
if (isNormal) {
holder.gameDownloadBtn.setText("下载中");
holder.gameDownloadBtn.setText(R.string.downloading);
holder.gameDownloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
holder.gameDownloadBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.text_downloading_style));
}
@ -397,10 +397,10 @@ public class DownloadItemUtils {
if (TextUtils.isEmpty(msg)) {
DataUtils.onGameDownloadEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), entrance, "下载开始");
DownloadManager.createDownload(context, gameEntity, "下载", entrance, location);
DownloadManager.createDownload(context, gameEntity, context.getString(R.string.download), entrance, location);
Utils.toast(context, gameEntity.getName() + "已加入下载队列");
downloadBtn.setText("下载中");
downloadBtn.setText(R.string.downloading);
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
downloadBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.text_downloading_style));
@ -420,7 +420,7 @@ public class DownloadItemUtils {
DownloadManager.createDownload(context, gameEntity, "插件化", entrance, location);
Utils.toast(context, gameEntity.getName() + "已加入下载队列");
downloadBtn.setText("下载中");
downloadBtn.setText(R.string.downloading);
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
downloadBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.text_downloading_style));
@ -438,7 +438,7 @@ public class DownloadItemUtils {
if (downloadEntity != null) {
final String path = downloadEntity.getPath();
if (FileUtils.isEmptyFile(path)) {
Utils.toast(context, "解析包出错(可能被误删了),请重新下载");
Utils.toast(context, context.getString(R.string.install_failure_hint));
DownloadManager.getInstance(context).cancel(downloadEntity.getUrl());
if (gameEntity.getEntryMap() != null) {
gameEntity.getEntryMap().remove(apkEntity.getPlatform());