package t3;

import A1.y;
import android.content.ContentResolver;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Looper;
import android.provider.Settings;
import android.util.AndroidRuntimeException;
import android.view.Choreographer;
import b0.C0524a;
import b0.C0527d;
import b0.C0528e;
import java.util.ArrayList;

/* JADX INFO: renamed from: t3.f, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class C1543f extends AbstractC1545h {

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public static final C1542e f16974G = new C1542e();

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public final C1548k f16975B;

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public final C0528e f16976C;
    public final C0527d D;

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public float f16977E;

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public boolean f16978F;

    public C1543f(Context context, C1551n c1551n, C1548k c1548k) {
        super(context, c1551n);
        this.f16978F = false;
        this.f16975B = c1548k;
        c1548k.f16993b = this;
        C0528e c0528e = new C0528e();
        this.f16976C = c0528e;
        c0528e.f9158b = 1.0f;
        c0528e.f9159c = false;
        c0528e.f9157a = Math.sqrt(50.0f);
        c0528e.f9159c = false;
        C0527d c0527d = new C0527d(this);
        this.D = c0527d;
        c0527d.f9155k = c0528e;
        if (this.f16989x != 1.0f) {
            this.f16989x = 1.0f;
            invalidateSelf();
        }
    }

    @Override // t3.AbstractC1545h
    public final boolean d(boolean z8, boolean z9, boolean z10) {
        boolean zD = super.d(z8, z9, z10);
        C1538a c1538a = this.f16984s;
        ContentResolver contentResolver = this.f16982q.getContentResolver();
        c1538a.getClass();
        float f3 = Settings.Global.getFloat(contentResolver, "animator_duration_scale", 1.0f);
        if (f3 == 0.0f) {
            this.f16978F = true;
            return zD;
        }
        this.f16978F = false;
        float f7 = 50.0f / f3;
        C0528e c0528e = this.f16976C;
        c0528e.getClass();
        if (f7 <= 0.0f) {
            throw new IllegalArgumentException("Spring stiffness constant must be positive.");
        }
        c0528e.f9157a = Math.sqrt(f7);
        c0528e.f9159c = false;
        return zD;
    }

    @Override // android.graphics.drawable.Drawable
    public final void draw(Canvas canvas) {
        Rect rect = new Rect();
        if (!getBounds().isEmpty() && isVisible() && canvas.getClipBounds(rect)) {
            canvas.save();
            this.f16975B.a(canvas, b());
            C1548k c1548k = this.f16975B;
            Paint paint = this.f16990y;
            c1548k.d(canvas, paint);
            this.f16975B.c(canvas, paint, 0.0f, this.f16977E, W2.g.h(this.f16983r.f17017c[0], this.f16991z));
            canvas.restore();
        }
    }

    @Override // android.graphics.drawable.Drawable
    public final int getIntrinsicHeight() {
        return this.f16975B.f16992a.f17015a;
    }

    @Override // android.graphics.drawable.Drawable
    public final int getIntrinsicWidth() {
        this.f16975B.getClass();
        return -1;
    }

    @Override // android.graphics.drawable.Drawable
    public final void jumpToCurrentState() {
        C0527d c0527d = this.D;
        c0527d.getClass();
        if (Looper.myLooper() != Looper.getMainLooper()) {
            throw new AndroidRuntimeException("Animations may only be canceled on the main thread");
        }
        if (c0527d.f9151f) {
            c0527d.a();
        }
        this.f16977E = getLevel() / 10000.0f;
        invalidateSelf();
    }

    @Override // android.graphics.drawable.Drawable
    public final boolean onLevelChange(int i) {
        boolean z8 = this.f16978F;
        C0527d c0527d = this.D;
        if (z8) {
            c0527d.getClass();
            if (Looper.myLooper() != Looper.getMainLooper()) {
                throw new AndroidRuntimeException("Animations may only be canceled on the main thread");
            }
            if (c0527d.f9151f) {
                c0527d.a();
            }
            this.f16977E = i / 10000.0f;
            invalidateSelf();
            return true;
        }
        c0527d.f9147b = this.f16977E * 10000.0f;
        c0527d.f9148c = true;
        float f3 = i;
        if (c0527d.f9151f) {
            c0527d.f9156l = f3;
            return true;
        }
        if (c0527d.f9155k == null) {
            c0527d.f9155k = new C0528e(f3);
        }
        C0528e c0528e = c0527d.f9155k;
        double d8 = f3;
        c0528e.i = d8;
        double d9 = (float) d8;
        if (d9 > Float.MAX_VALUE) {
            throw new UnsupportedOperationException("Final position of the spring cannot be greater than the max value.");
        }
        if (d9 < -3.4028235E38f) {
            throw new UnsupportedOperationException("Final position of the spring cannot be less than the min value.");
        }
        double dAbs = Math.abs(c0527d.f9153h * 0.75f);
        c0528e.f9160d = dAbs;
        c0528e.f9161e = dAbs * 62.5d;
        if (Looper.myLooper() != Looper.getMainLooper()) {
            throw new AndroidRuntimeException("Animations may only be started on the main thread");
        }
        boolean z9 = c0527d.f9151f;
        if (!z9 && !z9) {
            c0527d.f9151f = true;
            if (!c0527d.f9148c) {
                c0527d.f9150e.getClass();
                c0527d.f9147b = c0527d.f9149d.f16977E * 10000.0f;
            }
            float f7 = c0527d.f9147b;
            if (f7 > Float.MAX_VALUE || f7 < -3.4028235E38f) {
                throw new IllegalArgumentException("Starting value need to be in between min value and max value");
            }
            ThreadLocal threadLocal = C0524a.f9132f;
            if (threadLocal.get() == null) {
                threadLocal.set(new C0524a());
            }
            C0524a c0524a = (C0524a) threadLocal.get();
            ArrayList arrayList = c0524a.f9134b;
            if (arrayList.size() == 0) {
                if (c0524a.f9136d == null) {
                    c0524a.f9136d = new y(c0524a.f9135c);
                }
                y yVar = c0524a.f9136d;
                ((Choreographer) yVar.f364s).postFrameCallback((U.e) yVar.f365t);
            }
            if (!arrayList.contains(c0527d)) {
                arrayList.add(c0527d);
                return true;
            }
        }
        return true;
    }
}
