package com.ubt.jimu.connect.view; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.RectF; import android.util.AttributeSet; import android.view.View; import com.ubt.jimu.R$styleable; /* loaded from: classes.dex */ public class CircleProgressBar extends View { private Paint a; private Paint b; private Paint c; private Paint d; private int e; private int f; private int g; private float h; private float i; private float j; private int k; private int l; private int m; private int n; public CircleProgressBar(Context context, AttributeSet attributeSet) { super(context, attributeSet); this.m = 100; a(context, attributeSet); a(); } private void a(Context context, AttributeSet attributeSet) { TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(attributeSet, R$styleable.TasksCompletedView, 0, 0); this.h = obtainStyledAttributes.getDimension(1, 80.0f); this.j = obtainStyledAttributes.getDimension(4, 10.0f); this.e = obtainStyledAttributes.getColor(0, -1); this.f = obtainStyledAttributes.getColor(3, -1); this.g = obtainStyledAttributes.getColor(2, -1); this.i = this.h + (this.j / 2.0f); } @Override // android.view.View protected void onDraw(Canvas canvas) { this.k = getWidth() / 2; this.l = getHeight() / 2; canvas.drawCircle(this.k, this.l, this.h, this.a); RectF rectF = new RectF(); int i = this.k; float f = this.i; rectF.left = i - f; int i2 = this.l; rectF.top = i2 - f; rectF.right = (f * 2.0f) + (i - f); rectF.bottom = (f * 2.0f) + (i2 - f); canvas.drawArc(rectF, 0.0f, 360.0f, false, this.c); if (this.n > 0) { RectF rectF2 = new RectF(); int i3 = this.k; float f2 = this.i; rectF2.left = i3 - f2; int i4 = this.l; rectF2.top = i4 - f2; rectF2.right = (f2 * 2.0f) + (i3 - f2); rectF2.bottom = (2.0f * f2) + (i4 - f2); canvas.drawArc(rectF2, -90.0f, (this.n / this.m) * (-1.0f) * 360.0f, false, this.b); } } public void setProgress(int i) { if (i < 0) { i = 0; } this.n = i; postInvalidate(); } private void a() { this.a = new Paint(); this.a.setAntiAlias(true); this.a.setColor(this.e); this.a.setStyle(Paint.Style.FILL); this.c = new Paint(); this.c.setAntiAlias(true); this.c.setColor(this.g); this.c.setStyle(Paint.Style.STROKE); this.c.setStrokeWidth(this.j); this.b = new Paint(); this.b.setAntiAlias(true); this.b.setColor(this.f); this.b.setStyle(Paint.Style.STROKE); this.b.setStrokeWidth(this.j); this.d = new Paint(); this.d.setAntiAlias(true); this.d.setStyle(Paint.Style.FILL); this.d.setColor(this.f); this.d.setTextSize(this.h / 2.0f); Paint.FontMetrics fontMetrics = this.d.getFontMetrics(); Math.ceil(fontMetrics.descent - fontMetrics.ascent); } }