我的光环-我的游戏完成

This commit is contained in:
kehaoyuan
2018-05-25 14:10:57 +08:00
parent ffbbd44beb
commit 2992e3ca64
20 changed files with 356 additions and 172 deletions

View File

@ -1,6 +1,7 @@
package com.gh.common.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
@ -38,7 +39,9 @@ public class DownloadProgressBar extends ProgressBar {
private String mText;
private boolean mIsRectStyle;
private int mDefaultColor;
private int mTextSize;
public DownloadProgressBar(Context context) {
super(context);
@ -46,6 +49,12 @@ public class DownloadProgressBar extends ProgressBar {
public DownloadProgressBar(Context context, AttributeSet attrs) {
super(context, attrs);
if (attrs != null) {
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.DownloadProgressBar);
mIsRectStyle = ta.getBoolean(R.styleable.DownloadProgressBar_rectStyle, false);
mTextSize = ta.getDimensionPixelSize(R.styleable.DownloadProgressBar_textSize, DisplayUtils.sp2px(getContext(), 14));
ta.recycle();
}
setMax(MAX_LENGTH);
setProgressDrawable(getResources().getDrawable(R.drawable.game_item_btn_download_style));
}
@ -66,7 +75,7 @@ public class DownloadProgressBar extends ProgressBar {
if (TextUtils.isEmpty(mText)) return;
mPaint.setColor(mDefaultColor == 0 ? ContextCompat.getColor(getContext(), R.color.theme) : mDefaultColor); // 初始化颜色
mPaint.setTextSize(DisplayUtils.sp2px(getContext(), 14));
mPaint.setTextSize(mTextSize);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mPaint.setXfermode(null);
create();
@ -100,29 +109,35 @@ public class DownloadProgressBar extends ProgressBar {
switch (downloadType) {
case NORMAL:
case INSTALL_NORMAL:
setProgressDrawable(getResources().getDrawable(R.drawable.game_item_btn_download_style));
setProgressDrawable(getResources().getDrawable(mIsRectStyle
? R.drawable.detail_download_normal_rect_style : R.drawable.game_item_btn_download_style));
mDefaultColor = Color.WHITE;
break;
case PLUGIN:
case INSTALL_PLUGIN:
setProgressDrawable(getResources().getDrawable(R.drawable.game_item_btn_plugin_style));
setProgressDrawable(getResources().getDrawable(mIsRectStyle
? R.drawable.detail_download_plugin_install_rect_style : R.drawable.game_item_btn_plugin_style));
mDefaultColor = Color.WHITE;
break;
case NONE:
setProgressDrawable(getResources().getDrawable(R.drawable.news_detail_comment));
setProgressDrawable(getResources().getDrawable(mIsRectStyle
? 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(R.drawable.detail_downloading_normal_style));
setProgressDrawable(getResources().getDrawable(mIsRectStyle
? R.drawable.detail_download_open_rect_style : R.drawable.detail_download_open_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
break;
case DOWNLOADING_NORMAL: // todo bug 和列表用相同的drawable会复用
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_style2));
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);
break;
case DOWNLOADING_PLUGIN:
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_plugin_style));
setProgressDrawable(getResources().getDrawable(mIsRectStyle
? R.drawable.detail_downloading_plugin_rect_style : R.drawable.detail_downloading_plugin_style));
mDefaultColor = ContextCompat.getColor(getContext(), R.color.btn_plugin);
break;
}