首页游戏重做(专题大图增强)

This commit is contained in:
kehaoyuan
2018-06-08 18:15:55 +08:00
parent deea0f3f83
commit 5f08dee0e0
24 changed files with 421 additions and 113 deletions

View File

@ -20,6 +20,9 @@ import com.gh.gamecenter.R;
public class DownloadProgressBar extends ProgressBar {
private static final int MAX_LENGTH = 1000;
private static final int DOWNLOAD_NORMAL_STYLE = 0;
private static final int DOWNLOAD_RECT_STYLE = 1;
private static final int DOWNLOAD_IMAGE_STYLE = 2;
public enum DownloadType {
NORMAL,
@ -39,7 +42,7 @@ public class DownloadProgressBar extends ProgressBar {
private String mText;
private boolean mIsRectStyle;
private int mDownloadStyle;
private int mDefaultColor;
private int mTextSize;
@ -51,7 +54,7 @@ public class DownloadProgressBar extends ProgressBar {
super(context, attrs);
if (attrs != null) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.DownloadProgressBar);
mIsRectStyle = ta.getBoolean(R.styleable.DownloadProgressBar_rectStyle, false);
mDownloadStyle = ta.getInteger(R.styleable.DownloadProgressBar_downloadStyle, DOWNLOAD_NORMAL_STYLE);
mTextSize = ta.getDimensionPixelSize(R.styleable.DownloadProgressBar_textSize, DisplayUtils.sp2px(getContext(), 14));
ta.recycle();
}
@ -86,7 +89,7 @@ public class DownloadProgressBar extends ProgressBar {
mPaint.setTextAlign(Paint.Align.CENTER);
srcCanvas.drawText(mText, getWidth() / 2, baseline, mPaint);
mPaint.setXfermode(mDuffXFerMode);
mPaint.setColor(Color.WHITE); // 反向颜色
mPaint.setColor(DOWNLOAD_IMAGE_STYLE == mDownloadStyle ? Color.BLACK : Color.WHITE); // 反向颜色
srcCanvas.drawRect(rectF, mPaint);
canvas.drawBitmap(srcBitmap, 0, 0, null);
@ -109,34 +112,66 @@ public class DownloadProgressBar extends ProgressBar {
switch (downloadType) {
case NORMAL:
case INSTALL_NORMAL:
setProgressDrawable(getResources().getDrawable(mIsRectStyle
? R.drawable.detail_download_normal_rect_style : R.drawable.game_item_btn_download_style));
mDefaultColor = Color.WHITE;
switch (mDownloadStyle) {
case DOWNLOAD_RECT_STYLE:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_normal_rect_style));
mDefaultColor = Color.WHITE;
break;
case DOWNLOAD_IMAGE_STYLE:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_normal_image_style));
mDefaultColor = Color.BLACK;
break;
default:
setProgressDrawable(getResources().getDrawable(R.drawable.game_item_btn_download_style));
mDefaultColor = Color.WHITE;
break;
}
break;
case PLUGIN:
case INSTALL_PLUGIN:
setProgressDrawable(getResources().getDrawable(mIsRectStyle
setProgressDrawable(getResources().getDrawable(mDownloadStyle == DOWNLOAD_RECT_STYLE
? R.drawable.detail_download_plugin_install_rect_style : R.drawable.game_item_btn_plugin_style));
mDefaultColor = Color.WHITE;
break;
case NONE:
setProgressDrawable(getResources().getDrawable(mIsRectStyle
setProgressDrawable(getResources().getDrawable(mDownloadStyle == DOWNLOAD_RECT_STYLE
? R.drawable.detail_download_none_rect_style : R.drawable.news_detail_comment));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.hint);
break;
case LAUNCH_OR_OPEN:
setProgress(0);
setProgressDrawable(getResources().getDrawable(mIsRectStyle
? R.drawable.detail_download_open_rect_style : R.drawable.detail_download_open_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
switch (mDownloadStyle) {
case DOWNLOAD_RECT_STYLE:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_open_rect_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
break;
case DOWNLOAD_IMAGE_STYLE:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_open_image_style));
mDefaultColor = Color.WHITE;
break;
default:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_download_open_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
break;
}
break;
case DOWNLOADING_NORMAL:
setProgressDrawable(getResources().getDrawable(mIsRectStyle
? R.drawable.detail_downloading_normal_rect_style : R.drawable.detail_downloading_normal_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
switch (mDownloadStyle) {
case DOWNLOAD_RECT_STYLE:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_rect_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
break;
case DOWNLOAD_IMAGE_STYLE:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_image_style));
mDefaultColor = Color.WHITE;
break;
default:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
break;
}
break;
case DOWNLOADING_PLUGIN:
setProgressDrawable(getResources().getDrawable(mIsRectStyle
setProgressDrawable(getResources().getDrawable(mDownloadStyle == DOWNLOAD_RECT_STYLE
? R.drawable.detail_downloading_plugin_rect_style : R.drawable.detail_downloading_plugin_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.btn_plugin);
break;