package com.seewo.ota.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.util.AttributeSet;
import android.view.View;
import com.seewo.ota.R;

/* JADX INFO: loaded from: classes.dex */
public class CircleProgressBar extends View {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private Paint f2626b;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private Path f2627f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private PathMeasure f2628g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private int f2629h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private int f2630i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private int f2631j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private int f2632k;
    private float[] l;
    private float[] m;

    public CircleProgressBar(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    private void a() {
        this.f2629h = getResources().getDimensionPixelSize(R.dimen.circle_progress_bg_width);
        this.f2630i = getResources().getDimensionPixelSize(R.dimen.circle_progress_progress_width);
        Paint paint = new Paint();
        this.f2626b = paint;
        paint.setAntiAlias(true);
        this.f2627f = new Path();
        this.f2628g = new PathMeasure();
    }

    @Override // android.view.View
    protected synchronized void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.save();
        canvas.translate(this.f2630i / 2.0f, this.f2630i / 2.0f);
        float f2 = this.f2631j / 100.0f;
        this.f2626b.setStyle(Paint.Style.STROKE);
        this.f2626b.setStrokeWidth(this.f2629h);
        this.f2626b.setColor(c.f.d.a.b(getContext(), R.color.ab_ota_main_color_70));
        canvas.drawCircle(this.f2632k, this.f2632k, this.f2632k, this.f2626b);
        this.f2626b.setStyle(Paint.Style.STROKE);
        this.f2626b.setStrokeWidth(this.f2630i);
        this.f2626b.setColor(c.f.d.a.b(getContext(), R.color.ab_ota_main_color));
        canvas.drawArc(0.0f, 0.0f, this.f2632k * 2, this.f2632k * 2, -90.0f, f2 * 360.0f, false, this.f2626b);
        if (this.f2631j > 0 && this.f2631j < 100) {
            canvas.rotate(-90.0f, this.f2632k, this.f2632k);
            this.f2626b.setStyle(Paint.Style.FILL);
            this.f2628g.getPosTan(this.f2628g.getLength() * f2, this.l, this.m);
            canvas.drawCircle(this.l[0], this.l[1], this.f2630i / 2.0f, this.f2626b);
            this.f2628g.getPosTan(0.0f, this.l, this.m);
            canvas.drawCircle(this.l[0], this.l[1], this.f2630i / 2.0f, this.f2626b);
        }
        canvas.restore();
    }

    @Override // android.view.View
    protected void onLayout(boolean z, int i2, int i3, int i4, int i5) {
        super.onLayout(z, i2, i3, i4, i5);
        int iMin = (Math.min(getWidth(), getHeight()) - this.f2630i) / 2;
        this.f2632k = iMin;
        this.f2627f.addCircle(iMin, iMin, iMin, Path.Direction.CW);
        this.f2628g.setPath(this.f2627f, true);
    }

    public synchronized void setProgress(int i2) {
        this.f2631j = i2;
        postInvalidate();
    }

    public CircleProgressBar(Context context, AttributeSet attributeSet, int i2) {
        super(context, attributeSet, i2);
        this.l = new float[2];
        this.m = new float[2];
        a();
    }
}
