package ῲ.㶋.K;

import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import com.google.android.material.progressindicator.BaseProgressIndicator;
import ඓ.K.K.K.C1293;
import ῲ.㗗.K.K.C2240;

/* renamed from: ῲ.㶋.K.㸾  reason: contains not printable characters */
/* compiled from: CircularProgressDrawable */
public class C2294 extends Drawable implements Animatable {

    /* renamed from: ᨨ  reason: contains not printable characters */
    public static final Interpolator f7918 = new C2240();

    /* renamed from: 㳳  reason: contains not printable characters */
    public static final int[] f7919 = {-16777216};

    /* renamed from: 㿎  reason: contains not printable characters */
    public static final Interpolator f7920 = new LinearInterpolator();

    /* renamed from: ʬ  reason: contains not printable characters */
    public float f7921;

    /* renamed from: ඓ  reason: contains not printable characters */
    public Animator f7922;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final C2295 f7923;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public boolean f7924;

    /* renamed from: 㴹  reason: contains not printable characters */
    public float f7925;

    /* renamed from: 㸾  reason: contains not printable characters */
    public Resources f7926;

    public C2294(Context context) {
        if (context != null) {
            this.f7926 = context.getResources();
            this.f7923 = new C2295();
            C2295 k = this.f7923;
            k.f7935 = f7919;
            k.m5987(0);
            C2295 k2 = this.f7923;
            k2.f7945 = 2.5f;
            k2.f7936.setStrokeWidth(2.5f);
            invalidateSelf();
            C2295 k3 = this.f7923;
            ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
            ofFloat.addUpdateListener(new C2291(this, k3));
            ofFloat.setRepeatCount(-1);
            ofFloat.setRepeatMode(1);
            ofFloat.setInterpolator(f7920);
            ofFloat.addListener(new C2289(this, k3));
            this.f7922 = ofFloat;
            return;
        }
        throw new NullPointerException();
    }

    public void draw(Canvas canvas) {
        Rect bounds = getBounds();
        canvas.save();
        canvas.rotate(this.f7921, bounds.exactCenterX(), bounds.exactCenterY());
        C2295 k = this.f7923;
        RectF rectF = k.f7938;
        float f = k.f7933;
        float f2 = (k.f7945 / 2.0f) + f;
        if (f <= 0.0f) {
            f2 = (((float) Math.min(bounds.width(), bounds.height())) / 2.0f) - Math.max((((float) k.f7941) * k.f7930) / 2.0f, k.f7945 / 2.0f);
        }
        rectF.set(((float) bounds.centerX()) - f2, ((float) bounds.centerY()) - f2, ((float) bounds.centerX()) + f2, ((float) bounds.centerY()) + f2);
        float f3 = k.f7932;
        float f4 = k.f7937;
        float f5 = (f3 + f4) * 360.0f;
        float f6 = ((k.f7943 + f4) * 360.0f) - f5;
        k.f7936.setColor(k.f7929);
        k.f7936.setAlpha(k.f7946);
        float f7 = k.f7945 / 2.0f;
        rectF.inset(f7, f7);
        canvas.drawCircle(rectF.centerX(), rectF.centerY(), rectF.width() / 2.0f, k.f7944);
        float f8 = -f7;
        rectF.inset(f8, f8);
        canvas.drawArc(rectF, f5, f6, false, k.f7936);
        if (k.f7928) {
            Path path = k.f7940;
            if (path == null) {
                k.f7940 = new Path();
                k.f7940.setFillType(Path.FillType.EVEN_ODD);
            } else {
                path.reset();
            }
            k.f7940.moveTo(0.0f, 0.0f);
            k.f7940.lineTo(((float) k.f7941) * k.f7930, 0.0f);
            Path path2 = k.f7940;
            float f9 = k.f7930;
            path2.lineTo((((float) k.f7941) * f9) / 2.0f, ((float) k.f7931) * f9);
            k.f7940.offset((rectF.centerX() + (Math.min(rectF.width(), rectF.height()) / 2.0f)) - ((((float) k.f7941) * k.f7930) / 2.0f), (k.f7945 / 2.0f) + rectF.centerY());
            k.f7940.close();
            k.f7927.setColor(k.f7929);
            k.f7927.setAlpha(k.f7946);
            canvas.save();
            canvas.rotate(f5 + f6, rectF.centerX(), rectF.centerY());
            canvas.drawPath(k.f7940, k.f7927);
            canvas.restore();
        }
        canvas.restore();
    }

    public int getAlpha() {
        return this.f7923.f7946;
    }

    public int getOpacity() {
        return -3;
    }

    public boolean isRunning() {
        return this.f7922.isRunning();
    }

    public void setAlpha(int i) {
        this.f7923.f7946 = i;
        invalidateSelf();
    }

    public void setColorFilter(ColorFilter colorFilter) {
        this.f7923.f7936.setColorFilter(colorFilter);
        invalidateSelf();
    }

    public void start() {
        this.f7922.cancel();
        C2295 k = this.f7923;
        float f = k.f7932;
        k.f7934 = f;
        float f2 = k.f7943;
        k.f7939 = f2;
        k.f7947 = k.f7937;
        if (f2 != f) {
            this.f7924 = true;
            this.f7922.setDuration(666);
            this.f7922.start();
            return;
        }
        k.m5987(0);
        C2295 k2 = this.f7923;
        k2.f7934 = 0.0f;
        k2.f7939 = 0.0f;
        k2.f7947 = 0.0f;
        k2.f7932 = 0.0f;
        k2.f7943 = 0.0f;
        k2.f7937 = 0.0f;
        this.f7922.setDuration(1332);
        this.f7922.start();
    }

    public void stop() {
        this.f7922.cancel();
        this.f7921 = 0.0f;
        this.f7923.m5988(false);
        this.f7923.m5987(0);
        C2295 k = this.f7923;
        k.f7934 = 0.0f;
        k.f7939 = 0.0f;
        k.f7947 = 0.0f;
        k.f7932 = 0.0f;
        k.f7943 = 0.0f;
        k.f7937 = 0.0f;
        invalidateSelf();
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m5983(float f, float f2, float f3, float f4) {
        C2295 k = this.f7923;
        float f5 = this.f7926.getDisplayMetrics().density;
        float f6 = f2 * f5;
        k.f7945 = f6;
        k.f7936.setStrokeWidth(f6);
        k.f7933 = f * f5;
        k.m5987(0);
        k.f7941 = (int) (f3 * f5);
        k.f7931 = (int) (f4 * f5);
    }

    /* renamed from: ῲ.㶋.K.㸾$K  reason: contains not printable characters */
    /* compiled from: CircularProgressDrawable */
    public static class C2295 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final Paint f7927 = new Paint();

        /* renamed from: Ԕ  reason: contains not printable characters */
        public boolean f7928;

        /* renamed from: Ԛ  reason: contains not printable characters */
        public int f7929;

        /* renamed from: ؿ  reason: contains not printable characters */
        public float f7930 = 1.0f;

        /* renamed from: ݜ  reason: contains not printable characters */
        public int f7931;

        /* renamed from: ඓ  reason: contains not printable characters */
        public float f7932 = 0.0f;

        /* renamed from: ᓣ  reason: contains not printable characters */
        public float f7933;

        /* renamed from: ᕣ  reason: contains not printable characters */
        public float f7934;

        /* renamed from: ᨨ  reason: contains not printable characters */
        public int[] f7935;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final Paint f7936 = new Paint();

        /* renamed from: ⁱ  reason: contains not printable characters */
        public float f7937 = 0.0f;

        /* renamed from: K  reason: contains not printable characters */
        public final RectF f7938 = new RectF();

        /* renamed from: 㑃  reason: contains not printable characters */
        public float f7939;

        /* renamed from: 㗗  reason: contains not printable characters */
        public Path f7940;

        /* renamed from: 㗽  reason: contains not printable characters */
        public int f7941;

        /* renamed from: 㳳  reason: contains not printable characters */
        public int f7942;

        /* renamed from: 㴹  reason: contains not printable characters */
        public float f7943 = 0.0f;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final Paint f7944 = new Paint();

        /* renamed from: 㿎  reason: contains not printable characters */
        public float f7945 = 5.0f;

        /* renamed from: 䀟  reason: contains not printable characters */
        public int f7946 = BaseProgressIndicator.MAX_ALPHA;

        /* renamed from: 䁗  reason: contains not printable characters */
        public float f7947;

        public C2295() {
            this.f7936.setStrokeCap(Paint.Cap.SQUARE);
            this.f7936.setAntiAlias(true);
            this.f7936.setStyle(Paint.Style.STROKE);
            this.f7927.setStyle(Paint.Style.FILL);
            this.f7927.setAntiAlias(true);
            this.f7944.setColor(0);
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m5989(int[] iArr) {
            this.f7935 = iArr;
            m5987(0);
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m5987(int i) {
            this.f7942 = i;
            this.f7929 = this.f7935[this.f7942];
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m5988(boolean z) {
            if (this.f7928 != z) {
                this.f7928 = z;
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m5986(int i) {
        if (i == 0) {
            m5983(11.0f, 3.0f, 12.0f, 6.0f);
        } else {
            m5983(7.5f, 2.5f, 10.0f, 5.0f);
        }
        invalidateSelf();
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m5985(float f, C2295 k, boolean z) {
        float f2;
        float f3;
        if (this.f7924) {
            m5984(f, k);
            float floor = (float) (Math.floor((double) (k.f7947 / 0.8f)) + 1.0d);
            float f4 = k.f7934;
            float f5 = k.f7939;
            k.f7932 = (((f5 - 0.01f) - f4) * f) + f4;
            k.f7943 = f5;
            float f6 = k.f7947;
            k.f7937 = C1293.m3403(floor, f6, f, f6);
        } else if (f != 1.0f || z) {
            float f7 = k.f7947;
            if (f < 0.5f) {
                float f8 = k.f7934;
                f2 = (f7918.getInterpolation(f / 0.5f) * 0.79f) + 0.01f + f8;
                f3 = f8;
            } else {
                f2 = k.f7934 + 0.79f;
                f3 = f2 - (((1.0f - f7918.getInterpolation((f - 0.5f) / 0.5f)) * 0.79f) + 0.01f);
            }
            k.f7932 = f3;
            k.f7943 = f2;
            k.f7937 = (0.20999998f * f) + f7;
            this.f7921 = (f + this.f7925) * 216.0f;
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m5984(float f, C2295 k) {
        if (f > 0.75f) {
            float f2 = (f - 0.75f) / 0.25f;
            int[] iArr = k.f7935;
            int i = k.f7942;
            int i2 = iArr[i];
            int i3 = iArr[(i + 1) % iArr.length];
            int i4 = (i2 >> 24) & BaseProgressIndicator.MAX_ALPHA;
            int i5 = (i2 >> 16) & BaseProgressIndicator.MAX_ALPHA;
            int i6 = (i2 >> 8) & BaseProgressIndicator.MAX_ALPHA;
            int i7 = i2 & BaseProgressIndicator.MAX_ALPHA;
            k.f7929 = ((i4 + ((int) (((float) (((i3 >> 24) & BaseProgressIndicator.MAX_ALPHA) - i4)) * f2))) << 24) | ((i5 + ((int) (((float) (((i3 >> 16) & BaseProgressIndicator.MAX_ALPHA) - i5)) * f2))) << 16) | ((i6 + ((int) (((float) (((i3 >> 8) & BaseProgressIndicator.MAX_ALPHA) - i6)) * f2))) << 8) | (i7 + ((int) (f2 * ((float) ((i3 & BaseProgressIndicator.MAX_ALPHA) - i7)))));
            return;
        }
        k.f7929 = k.f7935[k.f7942];
    }
}
