102 lines
2.9 KiB
Java
102 lines
2.9 KiB
Java
package com.ubt.jimu.widgets;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.BlurMaskFilter;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.EmbossMaskFilter;
|
|
import android.graphics.Paint;
|
|
import android.graphics.RectF;
|
|
import android.graphics.SweepGradient;
|
|
import android.util.AttributeSet;
|
|
import android.view.View;
|
|
import com.ubt.jimu.R;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class SweepGradientCircleProgressBar extends View {
|
|
private Paint a;
|
|
private Paint b;
|
|
private float[] c;
|
|
private float d;
|
|
private int[] e;
|
|
private float f;
|
|
private RectF g;
|
|
private boolean h;
|
|
private float i;
|
|
private int j;
|
|
private int k;
|
|
private int l;
|
|
|
|
public SweepGradientCircleProgressBar(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.c = new float[]{1.0f, 1.0f, 1.0f};
|
|
this.d = 0.4f;
|
|
this.e = new int[]{getContext().getResources().getColor(R.color.bg_A00A9FF), getContext().getResources().getColor(R.color.bg_A00A9FF)};
|
|
this.f = 10.0f;
|
|
this.h = false;
|
|
this.i = 3.5f;
|
|
this.j = 15;
|
|
this.k = 0;
|
|
this.l = 100;
|
|
a();
|
|
this.g = new RectF();
|
|
new EmbossMaskFilter(this.c, this.d, this.f, this.i);
|
|
new BlurMaskFilter(20.0f, BlurMaskFilter.Blur.NORMAL);
|
|
}
|
|
|
|
private void a() {
|
|
this.a = new Paint();
|
|
this.a.setAntiAlias(true);
|
|
this.a.setFlags(1);
|
|
this.a.setStyle(Paint.Style.STROKE);
|
|
this.a.setDither(true);
|
|
this.a.setStrokeJoin(Paint.Join.ROUND);
|
|
this.b = new Paint();
|
|
this.b.setAntiAlias(true);
|
|
this.b.setFlags(1);
|
|
this.b.setStyle(Paint.Style.STROKE);
|
|
this.b.setDither(false);
|
|
this.b.setStrokeJoin(Paint.Join.ROUND);
|
|
}
|
|
|
|
public int getMax() {
|
|
return this.l;
|
|
}
|
|
|
|
public int getProgress() {
|
|
return this.k;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected void onDraw(Canvas canvas) {
|
|
super.onDraw(canvas);
|
|
if (this.h) {
|
|
canvas.drawColor(0);
|
|
this.h = false;
|
|
}
|
|
a(canvas);
|
|
}
|
|
|
|
public void setMax(int i) {
|
|
this.l = i;
|
|
}
|
|
|
|
public void setProgress(int i) {
|
|
this.k = i;
|
|
invalidate();
|
|
}
|
|
|
|
private void a(Canvas canvas) {
|
|
int measuredWidth = getMeasuredWidth();
|
|
int measuredWidth2 = getMeasuredWidth() / 2;
|
|
int i = measuredWidth2 - this.j;
|
|
this.b.setStrokeCap(Paint.Cap.ROUND);
|
|
this.b.setStrokeWidth(this.j + 1);
|
|
this.g.set(measuredWidth2 - i, r0 - i, measuredWidth2 + i, i + r0);
|
|
this.b.setShader(null);
|
|
this.b.setColor(getResources().getColor(R.color.progress_secondary));
|
|
canvas.drawArc(this.g, 0.0f, 360.0f, false, this.b);
|
|
this.b.setShader(new SweepGradient(measuredWidth2, measuredWidth / 2, this.e, (float[]) null));
|
|
canvas.drawArc(this.g, 0.0f, (this.k / this.l) * 360.0f, false, this.b);
|
|
}
|
|
}
|