package o;

import android.content.res.Resources;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AnimationUtils;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class XL implements View.OnTouchListener {
    public static final int C = ViewConfiguration.getTapTimeout();
    public boolean A;
    public final C0097Dt B;
    public final C0311Ma l;
    public final AccelerateInterpolator m;
    public final C0097Dt n;

    /* renamed from: o, reason: collision with root package name */
    public RunnableC2017o3 f408o;
    public final float[] p;
    public final float[] q;
    public final int r;
    public final int s;
    public final float[] t;
    public final float[] u;
    public final float[] v;
    public boolean w;
    public boolean x;
    public boolean y;
    public boolean z;

    public XL(C0097Dt c0097Dt) {
        C0311Ma c0311Ma = new C0311Ma();
        c0311Ma.e = Long.MIN_VALUE;
        c0311Ma.g = -1L;
        c0311Ma.f = 0L;
        this.l = c0311Ma;
        this.m = new AccelerateInterpolator();
        float[] fArr = {0.0f, 0.0f};
        this.p = fArr;
        float[] fArr2 = {Float.MAX_VALUE, Float.MAX_VALUE};
        this.q = fArr2;
        float[] fArr3 = {0.0f, 0.0f};
        this.t = fArr3;
        float[] fArr4 = {0.0f, 0.0f};
        this.u = fArr4;
        float[] fArr5 = {Float.MAX_VALUE, Float.MAX_VALUE};
        this.v = fArr5;
        this.n = c0097Dt;
        float f = Resources.getSystem().getDisplayMetrics().density;
        float f2 = ((int) ((1575.0f * f) + 0.5f)) / 1000.0f;
        fArr5[0] = f2;
        fArr5[1] = f2;
        float f3 = ((int) ((f * 315.0f) + 0.5f)) / 1000.0f;
        fArr4[0] = f3;
        fArr4[1] = f3;
        this.r = 1;
        fArr2[0] = Float.MAX_VALUE;
        fArr2[1] = Float.MAX_VALUE;
        fArr[0] = 0.2f;
        fArr[1] = 0.2f;
        fArr3[0] = 0.001f;
        fArr3[1] = 0.001f;
        this.s = C;
        c0311Ma.a = 500;
        c0311Ma.b = 500;
        this.B = c0097Dt;
    }

    public static float b(float f, float f2, float f3) {
        return f > f3 ? f3 : f < f2 ? f2 : f;
    }

    /* JADX WARN: Removed duplicated region for block: B:12:0x003b A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:13:0x003c  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final float a(int r4, float r5, float r6, float r7) {
        /*
            r3 = this;
            float[] r0 = r3.p
            r0 = r0[r4]
            float[] r1 = r3.q
            r1 = r1[r4]
            float r0 = r0 * r6
            r2 = 0
            float r0 = b(r0, r2, r1)
            float r1 = r3.c(r5, r0)
            float r6 = r6 - r5
            float r5 = r3.c(r6, r0)
            float r5 = r5 - r1
            int r6 = (r5 > r2 ? 1 : (r5 == r2 ? 0 : -1))
            android.view.animation.AccelerateInterpolator r0 = r3.m
            if (r6 >= 0) goto L25
            float r5 = -r5
            float r5 = r0.getInterpolation(r5)
            float r5 = -r5
            goto L2d
        L25:
            int r6 = (r5 > r2 ? 1 : (r5 == r2 ? 0 : -1))
            if (r6 <= 0) goto L36
            float r5 = r0.getInterpolation(r5)
        L2d:
            r6 = -1082130432(0xffffffffbf800000, float:-1.0)
            r0 = 1065353216(0x3f800000, float:1.0)
            float r5 = b(r5, r6, r0)
            goto L37
        L36:
            r5 = r2
        L37:
            int r6 = (r5 > r2 ? 1 : (r5 == r2 ? 0 : -1))
            if (r6 != 0) goto L3c
            return r2
        L3c:
            float[] r0 = r3.t
            r0 = r0[r4]
            float[] r1 = r3.u
            r1 = r1[r4]
            float[] r2 = r3.v
            r4 = r2[r4]
            float r0 = r0 * r7
            if (r6 <= 0) goto L51
            float r5 = r5 * r0
            float r4 = b(r5, r1, r4)
            return r4
        L51:
            float r5 = -r5
            float r5 = r5 * r0
            float r4 = b(r5, r1, r4)
            float r4 = -r4
            return r4
        */
        throw new UnsupportedOperationException("Method not decompiled: o.XL.a(int, float, float, float):float");
    }

    public final float c(float f, float f2) {
        if (f2 != 0.0f) {
            int i = this.r;
            if (i == 0 || i == 1) {
                if (f < f2) {
                    if (f >= 0.0f) {
                        return 1.0f - (f / f2);
                    }
                    if (this.z && i == 1) {
                        return 1.0f;
                    }
                }
            } else if (i == 2 && f < 0.0f) {
                return f / (-f2);
            }
        }
        return 0.0f;
    }

    public final void d() {
        int i = 0;
        if (this.x) {
            this.z = false;
            return;
        }
        long jCurrentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis();
        C0311Ma c0311Ma = this.l;
        int i2 = (int) (jCurrentAnimationTimeMillis - c0311Ma.e);
        int i3 = c0311Ma.b;
        if (i2 > i3) {
            i = i3;
        } else if (i2 >= 0) {
            i = i2;
        }
        c0311Ma.i = i;
        c0311Ma.h = c0311Ma.a(jCurrentAnimationTimeMillis);
        c0311Ma.g = jCurrentAnimationTimeMillis;
    }

    public final boolean e() {
        C0097Dt c0097Dt;
        int count;
        C0311Ma c0311Ma = this.l;
        float f = c0311Ma.d;
        int iAbs = (int) (f / Math.abs(f));
        Math.abs(c0311Ma.c);
        if (iAbs != 0 && (count = (c0097Dt = this.B).getCount()) != 0) {
            int childCount = c0097Dt.getChildCount();
            int firstVisiblePosition = c0097Dt.getFirstVisiblePosition();
            int i = firstVisiblePosition + childCount;
            if (iAbs <= 0 ? !(iAbs >= 0 || (firstVisiblePosition <= 0 && c0097Dt.getChildAt(0).getTop() >= 0)) : !(i >= count && c0097Dt.getChildAt(childCount - 1).getBottom() <= c0097Dt.getHeight())) {
                return true;
            }
        }
        return false;
    }

    /* JADX WARN: Code restructure failed: missing block: B:11:0x0014, code lost:
    
        if (r0 != 3) goto L30;
     */
    @Override // android.view.View.OnTouchListener
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final boolean onTouch(android.view.View r8, android.view.MotionEvent r9) {
        /*
            r7 = this;
            boolean r0 = r7.A
            r1 = 0
            if (r0 != 0) goto L7
            goto L7c
        L7:
            int r0 = r9.getActionMasked()
            r2 = 1
            if (r0 == 0) goto L1b
            if (r0 == r2) goto L17
            r3 = 2
            if (r0 == r3) goto L1f
            r8 = 3
            if (r0 == r8) goto L17
            goto L7c
        L17:
            r7.d()
            return r1
        L1b:
            r7.y = r2
            r7.w = r1
        L1f:
            float r0 = r9.getX()
            int r3 = r8.getWidth()
            float r3 = (float) r3
            o.Dt r4 = r7.n
            int r5 = r4.getWidth()
            float r5 = (float) r5
            float r0 = r7.a(r1, r0, r3, r5)
            float r9 = r9.getY()
            int r8 = r8.getHeight()
            float r8 = (float) r8
            int r3 = r4.getHeight()
            float r3 = (float) r3
            float r8 = r7.a(r2, r9, r8, r3)
            o.Ma r9 = r7.l
            r9.c = r0
            r9.d = r8
            boolean r8 = r7.z
            if (r8 != 0) goto L7c
            boolean r8 = r7.e()
            if (r8 == 0) goto L7c
            o.o3 r8 = r7.f408o
            if (r8 != 0) goto L60
            o.o3 r8 = new o.o3
            r8.<init>(r2, r7)
            r7.f408o = r8
        L60:
            r7.z = r2
            r7.x = r2
            boolean r8 = r7.w
            if (r8 != 0) goto L75
            int r8 = r7.s
            if (r8 <= 0) goto L75
            o.o3 r9 = r7.f408o
            long r5 = (long) r8
            java.util.WeakHashMap r8 = o.Oj0.a
            r4.postOnAnimationDelayed(r9, r5)
            goto L7a
        L75:
            o.o3 r8 = r7.f408o
            r8.run()
        L7a:
            r7.w = r2
        L7c:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: o.XL.onTouch(android.view.View, android.view.MotionEvent):boolean");
    }
}
