package Z;

import D.C0135f;
import F1.r;
import android.R;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;
import android.view.animation.AnimationUtils;
import p0.AbstractC2686D;
import p0.C2714u;
import z.o;

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final int[] f9026f = {R.attr.state_pressed, R.attr.state_enabled};

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public static final int[] f9027j = new int[0];

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public j f9028a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Boolean f9029b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public Long f9030c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public r f9031d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public C0135f f9032e;

    private final void setRippleState(boolean z6) throws Throwable {
        long jCurrentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis();
        Runnable runnable = this.f9031d;
        if (runnable != null) {
            removeCallbacks(runnable);
            runnable.run();
        }
        Long l = this.f9030c;
        long jLongValue = jCurrentAnimationTimeMillis - (l != null ? l.longValue() : 0L);
        if (z6 || jLongValue >= 5) {
            int[] iArr = z6 ? f9026f : f9027j;
            j jVar = this.f9028a;
            if (jVar != null) {
                jVar.setState(iArr);
            }
        } else {
            r rVar = new r(this, 4);
            this.f9031d = rVar;
            postDelayed(rVar, 50L);
        }
        this.f9030c = Long.valueOf(jCurrentAnimationTimeMillis);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void setRippleState$lambda$1(e eVar) {
        j jVar = eVar.f9028a;
        if (jVar != null) {
            jVar.setState(f9027j);
        }
        eVar.f9031d = null;
    }

    public final void b(o oVar, boolean z6, long j4, int i6, long j6, C0135f c0135f) throws Throwable {
        if (this.f9028a == null || !Boolean.valueOf(z6).equals(this.f9029b)) {
            j jVar = new j(z6);
            setBackground(jVar);
            this.f9028a = jVar;
            this.f9029b = Boolean.valueOf(z6);
        }
        j jVar2 = this.f9028a;
        kotlin.jvm.internal.o.e(jVar2);
        this.f9032e = c0135f;
        e(i6, j4, j6);
        if (z6) {
            jVar2.setHotspot(Float.intBitsToFloat((int) (oVar.f26252a >> 32)), Float.intBitsToFloat((int) (4294967295L & oVar.f26252a)));
        } else {
            jVar2.setHotspot(jVar2.getBounds().centerX(), jVar2.getBounds().centerY());
        }
        setRippleState(true);
    }

    public final void c() throws Throwable {
        this.f9032e = null;
        r rVar = this.f9031d;
        if (rVar != null) {
            removeCallbacks(rVar);
            r rVar2 = this.f9031d;
            kotlin.jvm.internal.o.e(rVar2);
            rVar2.run();
        } else {
            j jVar = this.f9028a;
            if (jVar != null) {
                jVar.setState(f9027j);
            }
        }
        j jVar2 = this.f9028a;
        if (jVar2 == null) {
            return;
        }
        jVar2.setVisible(false, false);
        unscheduleDrawable(jVar2);
    }

    public final void d() throws Throwable {
        setRippleState(false);
    }

    @Override // android.view.View
    public final void draw(Canvas canvas) throws Throwable {
        if (isAttachedToWindow()) {
            super.draw(canvas);
        } else {
            c();
        }
    }

    public final void e(int i6, long j4, long j6) {
        j jVar = this.f9028a;
        if (jVar == null) {
            return;
        }
        Integer num = jVar.f9046c;
        if (num == null || num.intValue() != i6) {
            jVar.f9046c = Integer.valueOf(i6);
            jVar.setRadius(i6);
        }
        float f6 = Build.VERSION.SDK_INT < 28 ? 0.1f * 2 : 0.1f;
        if (f6 > 1.0f) {
            f6 = 1.0f;
        }
        long jC = C2714u.c(f6, j6);
        C2714u c2714u = jVar.f9045b;
        if (!(c2714u == null ? false : C2714u.d(c2714u.f22947a, jC))) {
            jVar.f9045b = new C2714u(jC);
            jVar.setColor(ColorStateList.valueOf(AbstractC2686D.I(jC)));
        }
        Rect rect = new Rect(0, 0, L4.a.d0(o0.e.d(j4)), L4.a.d0(o0.e.b(j4)));
        setLeft(rect.left);
        setTop(rect.top);
        setRight(rect.right);
        setBottom(rect.bottom);
        jVar.setBounds(rect);
    }

    @Override // android.view.View, android.graphics.drawable.Drawable.Callback
    public final void invalidateDrawable(Drawable drawable) {
        C0135f c0135f = this.f9032e;
        if (c0135f != null) {
            c0135f.invoke();
        }
    }

    @Override // android.view.View
    public final void onMeasure(int i6, int i7) {
        setMeasuredDimension(0, 0);
    }

    @Override // android.view.View
    public final void refreshDrawableState() {
    }

    @Override // android.view.View
    public final void onLayout(boolean z6, int i6, int i7, int i8, int i9) {
    }
}
