DownloadProgressBar add slide style
This commit is contained in:
@ -22,10 +22,11 @@ import com.gh.common.util.DisplayUtils;
|
||||
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 static final int MAX_LENGTH = 1000;
|
||||
public static final int DOWNLOAD_NORMAL_STYLE = 0;
|
||||
public static final int DOWNLOAD_RECT_STYLE = 1;
|
||||
public static final int DOWNLOAD_IMAGE_STYLE = 2;
|
||||
public static final int DOWNLOAD_SLIDE_STYLE = 3;
|
||||
|
||||
public enum DownloadType {
|
||||
NORMAL,
|
||||
@ -110,7 +111,13 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
srcCanvas.drawText(txt, getWidth() / 2, baseline, mPaint);
|
||||
mPaint.setXfermode(mDuffXFerMode);
|
||||
if (getProgress() != 0) {
|
||||
mPaint.setColor(DOWNLOAD_IMAGE_STYLE == mDownloadStyle ? Color.BLACK : Color.WHITE); // 反向颜色
|
||||
int color = Color.WHITE;
|
||||
if (DOWNLOAD_IMAGE_STYLE == mDownloadStyle) {
|
||||
color = Color.BLACK;
|
||||
} else if (DOWNLOAD_SLIDE_STYLE == mDownloadStyle) {
|
||||
color = getResources().getColor(R.color.theme);
|
||||
}
|
||||
mPaint.setColor(color); // 反向颜色
|
||||
}
|
||||
|
||||
srcCanvas.drawRect(rectF, mPaint);
|
||||
@ -137,6 +144,10 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
}
|
||||
}
|
||||
|
||||
public void setDownloadStyle(int downloadStyle) {
|
||||
this.mDownloadStyle = downloadStyle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setProgress(int progress) {
|
||||
super.setProgress(progress);
|
||||
@ -207,6 +218,7 @@ public class DownloadProgressBar extends ProgressBar {
|
||||
mDefaultColor = ContextCompat.getColor(getContext(), R.color.theme);
|
||||
break;
|
||||
case DOWNLOAD_IMAGE_STYLE:
|
||||
case DOWNLOAD_SLIDE_STYLE:
|
||||
setProgressDrawable(getResources().getDrawable(R.drawable.detail_downloading_normal_image_style));
|
||||
mDefaultColor = Color.WHITE;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user