package u0;

import android.R;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.animation.AnimationUtils;
import d0.n;

/* loaded from: classes.dex */
public final class n extends View {

    /* renamed from: u, reason: collision with root package name */
    public static final a f36708u = new a(null);

    /* renamed from: v, reason: collision with root package name */
    public static final int f36709v = 8;

    /* renamed from: w, reason: collision with root package name */
    private static final int[] f36710w = {R.attr.state_pressed, R.attr.state_enabled};

    /* renamed from: x, reason: collision with root package name */
    private static final int[] f36711x = new int[0];

    /* renamed from: p, reason: collision with root package name */
    private v f36712p;

    /* renamed from: q, reason: collision with root package name */
    private Boolean f36713q;

    /* renamed from: r, reason: collision with root package name */
    private Long f36714r;

    /* renamed from: s, reason: collision with root package name */
    private Runnable f36715s;

    /* renamed from: t, reason: collision with root package name */
    private dn.a f36716t;

    /* loaded from: classes.dex */
    public static final class a {
        private a() {
        }

        public /* synthetic */ a(kotlin.jvm.internal.k kVar) {
            this();
        }
    }

    public n(Context context) {
        super(context);
    }

    private final void c(boolean z10) {
        v vVar = new v(z10);
        setBackground(vVar);
        this.f36712p = vVar;
    }

    private final void setRippleState(boolean z10) {
        long currentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis();
        Runnable runnable = this.f36715s;
        if (runnable != null) {
            removeCallbacks(runnable);
            runnable.run();
        }
        Long l10 = this.f36714r;
        long longValue = currentAnimationTimeMillis - (l10 != null ? l10.longValue() : 0L);
        if (z10 || longValue >= 5) {
            int[] iArr = z10 ? f36710w : f36711x;
            v vVar = this.f36712p;
            if (vVar != null) {
                vVar.setState(iArr);
            }
        } else {
            Runnable runnable2 = new Runnable() { // from class: u0.m
                @Override // java.lang.Runnable
                public final void run() {
                    n.setRippleState$lambda$2(n.this);
                }
            };
            this.f36715s = runnable2;
            postDelayed(runnable2, 50L);
        }
        this.f36714r = Long.valueOf(currentAnimationTimeMillis);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void setRippleState$lambda$2(n nVar) {
        v vVar = nVar.f36712p;
        if (vVar != null) {
            vVar.setState(f36711x);
        }
        nVar.f36715s = null;
    }

    public final void b(n.b bVar, boolean z10, long j10, int i10, long j11, float f10, dn.a aVar) {
        if (this.f36712p == null || !kotlin.jvm.internal.t.b(Boolean.valueOf(z10), this.f36713q)) {
            c(z10);
            this.f36713q = Boolean.valueOf(z10);
        }
        v vVar = this.f36712p;
        kotlin.jvm.internal.t.d(vVar);
        this.f36716t = aVar;
        vVar.c(i10);
        f(j10, j11, f10);
        if (z10) {
            vVar.setHotspot(r1.g.m(bVar.a()), r1.g.n(bVar.a()));
        } else {
            vVar.setHotspot(vVar.getBounds().centerX(), vVar.getBounds().centerY());
        }
        setRippleState(true);
    }

    public final void d() {
        this.f36716t = null;
        Runnable runnable = this.f36715s;
        if (runnable != null) {
            removeCallbacks(runnable);
            Runnable runnable2 = this.f36715s;
            kotlin.jvm.internal.t.d(runnable2);
            runnable2.run();
        } else {
            v vVar = this.f36712p;
            if (vVar != null) {
                vVar.setState(f36711x);
            }
        }
        v vVar2 = this.f36712p;
        if (vVar2 == null) {
            return;
        }
        vVar2.setVisible(false, false);
        unscheduleDrawable(vVar2);
    }

    public final void e() {
        setRippleState(false);
    }

    public final void f(long j10, long j11, float f10) {
        int c10;
        int c11;
        v vVar = this.f36712p;
        if (vVar == null) {
            return;
        }
        vVar.b(j11, f10);
        c10 = fn.c.c(r1.m.i(j10));
        c11 = fn.c.c(r1.m.g(j10));
        Rect rect = new Rect(0, 0, c10, c11);
        setLeft(rect.left);
        setTop(rect.top);
        setRight(rect.right);
        setBottom(rect.bottom);
        vVar.setBounds(rect);
    }

    @Override // android.view.View, android.graphics.drawable.Drawable.Callback
    public void invalidateDrawable(Drawable drawable) {
        dn.a aVar = this.f36716t;
        if (aVar != null) {
            aVar.invoke();
        }
    }

    @Override // android.view.View
    protected void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
    }

    @Override // android.view.View
    protected void onMeasure(int i10, int i11) {
        setMeasuredDimension(0, 0);
    }

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