This commit is contained in:
huangzhuanghua
2016-09-08 18:48:56 +08:00
18 changed files with 88 additions and 55 deletions

View File

@ -2,6 +2,7 @@ package com.gh.common.util;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.os.Message;
import android.support.v4.util.ArrayMap;
@ -259,6 +260,13 @@ public class DownloadItemUtils {
String platform = PlatformUtils.getInstance(context)
.getPlatformName(downloadEntry.getMeta().get("platform"));
int[] btn_colors = new int[] { Color.WHITE
, context.getResources().getColor(R.color.theme) };
int[][] states = new int[2][];
states[0] = new int[] { android.R.attr.state_pressed };
states[1] = new int[] {};
ColorStateList btn_sl = new ColorStateList(states, btn_colors);
DownloadStatus status = downloadEntry.getStatus();
if (status.equals(DownloadStatus.downloading)) {
if (!"pause".equals(DownloadManager.getInstance(context).getStatus(downloadEntry.getUrl()))) {
@ -277,7 +285,7 @@ public class DownloadItemUtils {
if (isNormal) {
downloadBtn.setText("下载中");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
downloadBtn.setTextColor(context.getResources().getColor(R.color.theme));
downloadBtn.setTextColor(btn_sl);
}
} else if (status.equals(DownloadStatus.waiting)) {
game_progressbar.setProgress((int) (downloadEntry.getPercent() * 10));
@ -291,7 +299,7 @@ public class DownloadItemUtils {
if (isNormal) {
downloadBtn.setText("下载中");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
downloadBtn.setTextColor(context.getResources().getColor(R.color.theme));
downloadBtn.setTextColor(btn_sl);
}
} else if (status.equals(DownloadStatus.pause)
|| status.equals(DownloadStatus.timeout)
@ -307,7 +315,7 @@ public class DownloadItemUtils {
if (isNormal) {
downloadBtn.setText("下载中");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
downloadBtn.setTextColor(context.getResources().getColor(R.color.theme));
downloadBtn.setTextColor(btn_sl);
}
} else if (status.equals(DownloadStatus.done)) {
game_progressbar.setProgress(1000);
@ -538,9 +546,17 @@ public class DownloadItemUtils {
addDownloadEntry(context, entity, 0, entrance);
Toast.makeText(context, entity.getName() + "已加入下载队列", Toast.LENGTH_SHORT).show();
int[] btn_colors = new int[] { Color.WHITE
, context.getResources().getColor(R.color.theme) };
int[][] states = new int[2][];
states[0] = new int[] { android.R.attr.state_pressed };
states[1] = new int[] {};
ColorStateList btn_sl = new ColorStateList(states, btn_colors);
downloadBtn.setText("下载中");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
downloadBtn.setTextColor(context.getResources().getColor(R.color.theme));
downloadBtn.setTextColor(btn_sl);
EventBus.getDefault().post(new EBRedDot(1));
DownloadManager.getInstance(context).putStatus(entity.getApk().get(0).getUrl(), "downloading");
@ -600,9 +616,17 @@ public class DownloadItemUtils {
addDownloadEntry(context, entity, 0, entrance);
Toast.makeText(context, entity.getName() + "已加入下载队列", Toast.LENGTH_SHORT).show();
int[] btn_colors = new int[] { Color.WHITE
, context.getResources().getColor(R.color.theme) };
int[][] states = new int[2][];
states[0] = new int[] { android.R.attr.state_pressed };
states[1] = new int[] {};
ColorStateList btn_sl = new ColorStateList(states, btn_colors);
downloadBtn.setText("下载中");
downloadBtn.setBackgroundResource(R.drawable.game_item_btn_downloading_style);
downloadBtn.setTextColor(context.getResources().getColor(R.color.theme));
downloadBtn.setTextColor(btn_sl);
EventBus.getDefault().post(new EBRedDot(1));
DownloadManager.getInstance(context).putStatus(entity.getApk().get(0).getUrl(), "downloading");