package c.f.k;

import android.content.res.Resources;
import android.os.SystemClock;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import c.f.j.a0;
import c.f.j.i0;
import java.util.Objects;
import java.util.WeakHashMap;

/* JADX INFO: compiled from: AutoScrollHelper.java */
/* JADX INFO: loaded from: classes.dex */
public abstract class a implements View.OnTouchListener {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final int f1477b = ViewConfiguration.getTapTimeout();

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final C0011a f1478e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final Interpolator f1479f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final View f1480g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public Runnable f1481h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public float[] f1482i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public float[] f1483j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f1484k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f1485l;
    public float[] m;
    public float[] n;
    public float[] o;
    public boolean p;
    public boolean q;
    public boolean r;
    public boolean s;
    public boolean t;

    /* JADX INFO: renamed from: c.f.k.a$a, reason: collision with other inner class name */
    /* JADX INFO: compiled from: AutoScrollHelper.java */
    public static class C0011a {
        public int a;

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

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

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

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

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        public int f1495k;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public long f1489e = Long.MIN_VALUE;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        public long f1493i = -1;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public long f1490f = 0;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        public int f1491g = 0;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        public int f1492h = 0;

        public final float a(long j2) {
            if (j2 < this.f1489e) {
                return 0.0f;
            }
            long j3 = this.f1493i;
            if (j3 < 0 || j2 < j3) {
                return a.b((j2 - r0) / this.a, 0.0f, 1.0f) * 0.5f;
            }
            float f2 = this.f1494j;
            return (a.b((j2 - j3) / this.f1495k, 0.0f, 1.0f) * f2) + (1.0f - f2);
        }
    }

    /* JADX INFO: compiled from: AutoScrollHelper.java */
    public class b implements Runnable {
        public b() {
        }

        @Override // java.lang.Runnable
        public void run() {
            a aVar = a.this;
            if (aVar.s) {
                if (aVar.q) {
                    aVar.q = false;
                    C0011a c0011a = aVar.f1478e;
                    Objects.requireNonNull(c0011a);
                    long jCurrentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis();
                    c0011a.f1489e = jCurrentAnimationTimeMillis;
                    c0011a.f1493i = -1L;
                    c0011a.f1490f = jCurrentAnimationTimeMillis;
                    c0011a.f1494j = 0.5f;
                    c0011a.f1491g = 0;
                    c0011a.f1492h = 0;
                }
                C0011a c0011a2 = a.this.f1478e;
                if ((c0011a2.f1493i > 0 && AnimationUtils.currentAnimationTimeMillis() > c0011a2.f1493i + ((long) c0011a2.f1495k)) || !a.this.e()) {
                    a.this.s = false;
                    return;
                }
                a aVar2 = a.this;
                if (aVar2.r) {
                    aVar2.r = false;
                    Objects.requireNonNull(aVar2);
                    long jUptimeMillis = SystemClock.uptimeMillis();
                    MotionEvent motionEventObtain = MotionEvent.obtain(jUptimeMillis, jUptimeMillis, 3, 0.0f, 0.0f, 0);
                    aVar2.f1480g.onTouchEvent(motionEventObtain);
                    motionEventObtain.recycle();
                }
                if (c0011a2.f1490f == 0) {
                    throw new RuntimeException("Cannot compute scroll delta before calling start()");
                }
                long jCurrentAnimationTimeMillis2 = AnimationUtils.currentAnimationTimeMillis();
                float fA = c0011a2.a(jCurrentAnimationTimeMillis2);
                long j2 = jCurrentAnimationTimeMillis2 - c0011a2.f1490f;
                c0011a2.f1490f = jCurrentAnimationTimeMillis2;
                float f2 = j2 * ((fA * 4.0f) + ((-4.0f) * fA * fA));
                c0011a2.f1491g = (int) (c0011a2.f1487c * f2);
                int i2 = (int) (f2 * c0011a2.f1488d);
                c0011a2.f1492h = i2;
                h.b(((g) a.this).u, i2);
                View view = a.this.f1480g;
                WeakHashMap<View, i0> weakHashMap = a0.a;
                a0.d.m(view, this);
            }
        }
    }

    public a(View view) {
        C0011a c0011a = new C0011a();
        this.f1478e = c0011a;
        this.f1479f = new AccelerateInterpolator();
        this.f1482i = new float[]{0.0f, 0.0f};
        this.f1483j = new float[]{Float.MAX_VALUE, Float.MAX_VALUE};
        this.m = new float[]{0.0f, 0.0f};
        this.n = new float[]{0.0f, 0.0f};
        this.o = new float[]{Float.MAX_VALUE, Float.MAX_VALUE};
        this.f1480g = view;
        float f2 = Resources.getSystem().getDisplayMetrics().density;
        float[] fArr = this.o;
        float f3 = ((int) ((1575.0f * f2) + 0.5f)) / 1000.0f;
        fArr[0] = f3;
        fArr[1] = f3;
        float[] fArr2 = this.n;
        float f4 = ((int) ((f2 * 315.0f) + 0.5f)) / 1000.0f;
        fArr2[0] = f4;
        fArr2[1] = f4;
        this.f1484k = 1;
        float[] fArr3 = this.f1483j;
        fArr3[0] = Float.MAX_VALUE;
        fArr3[1] = Float.MAX_VALUE;
        float[] fArr4 = this.f1482i;
        fArr4[0] = 0.2f;
        fArr4[1] = 0.2f;
        float[] fArr5 = this.m;
        fArr5[0] = 0.001f;
        fArr5[1] = 0.001f;
        this.f1485l = f1477b;
        c0011a.a = 500;
        c0011a.f1486b = 500;
    }

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

    /* JADX WARN: Removed duplicated region for block: B:12:0x003d A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:13:0x003e  */
    /*
        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.f1482i
            r0 = r0[r4]
            float[] r1 = r3.f1483j
            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))
            if (r6 >= 0) goto L25
            android.view.animation.Interpolator r6 = r3.f1479f
            float r5 = -r5
            float r5 = r6.getInterpolation(r5)
            float r5 = -r5
            goto L2f
        L25:
            int r6 = (r5 > r2 ? 1 : (r5 == r2 ? 0 : -1))
            if (r6 <= 0) goto L38
            android.view.animation.Interpolator r6 = r3.f1479f
            float r5 = r6.getInterpolation(r5)
        L2f:
            r6 = -1082130432(0xffffffffbf800000, float:-1.0)
            r0 = 1065353216(0x3f800000, float:1.0)
            float r5 = b(r5, r6, r0)
            goto L39
        L38:
            r5 = r2
        L39:
            int r6 = (r5 > r2 ? 1 : (r5 == r2 ? 0 : -1))
            if (r6 != 0) goto L3e
            return r2
        L3e:
            float[] r0 = r3.m
            r0 = r0[r4]
            float[] r1 = r3.n
            r1 = r1[r4]
            float[] r2 = r3.o
            r4 = r2[r4]
            float r0 = r0 * r7
            if (r6 <= 0) goto L53
            float r5 = r5 * r0
            float r4 = b(r5, r1, r4)
            return r4
        L53:
            float r5 = -r5
            float r5 = r5 * r0
            float r4 = b(r5, r1, r4)
            float r4 = -r4
            return r4
        */
        throw new UnsupportedOperationException("Method not decompiled: c.f.k.a.a(int, float, float, float):float");
    }

    public final float c(float f2, float f3) {
        if (f3 == 0.0f) {
            return 0.0f;
        }
        int i2 = this.f1484k;
        if (i2 == 0 || i2 == 1) {
            if (f2 < f3) {
                if (f2 >= 0.0f) {
                    return 1.0f - (f2 / f3);
                }
                if (this.s && i2 == 1) {
                    return 1.0f;
                }
            }
        } else if (i2 == 2 && f2 < 0.0f) {
            return f2 / (-f3);
        }
        return 0.0f;
    }

    public final void d() {
        int i2 = 0;
        if (this.q) {
            this.s = false;
            return;
        }
        C0011a c0011a = this.f1478e;
        Objects.requireNonNull(c0011a);
        long jCurrentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis();
        int i3 = (int) (jCurrentAnimationTimeMillis - c0011a.f1489e);
        int i4 = c0011a.f1486b;
        if (i3 > i4) {
            i2 = i4;
        } else if (i3 >= 0) {
            i2 = i3;
        }
        c0011a.f1495k = i2;
        c0011a.f1494j = c0011a.a(jCurrentAnimationTimeMillis);
        c0011a.f1493i = jCurrentAnimationTimeMillis;
    }

    /* JADX WARN: Removed duplicated region for block: B:22:? A[RETURN, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:6:0x0021  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean e() {
        /*
            r9 = this;
            c.f.k.a$a r0 = r9.f1478e
            float r1 = r0.f1488d
            float r2 = java.lang.Math.abs(r1)
            float r1 = r1 / r2
            int r1 = (int) r1
            float r0 = r0.f1487c
            float r2 = java.lang.Math.abs(r0)
            float r0 = r0 / r2
            int r0 = (int) r0
            r2 = 1
            r3 = 0
            if (r1 == 0) goto L53
            r4 = r9
            c.f.k.g r4 = (c.f.k.g) r4
            android.widget.ListView r4 = r4.u
            int r5 = r4.getCount()
            if (r5 != 0) goto L23
        L21:
            r1 = r3
            goto L51
        L23:
            int r6 = r4.getChildCount()
            int r7 = r4.getFirstVisiblePosition()
            int r8 = r7 + r6
            if (r1 <= 0) goto L41
            if (r8 < r5) goto L50
            int r6 = r6 - r2
            android.view.View r1 = r4.getChildAt(r6)
            int r1 = r1.getBottom()
            int r4 = r4.getHeight()
            if (r1 > r4) goto L50
            goto L21
        L41:
            if (r1 >= 0) goto L21
            if (r7 > 0) goto L50
            android.view.View r1 = r4.getChildAt(r3)
            int r1 = r1.getTop()
            if (r1 < 0) goto L50
            goto L21
        L50:
            r1 = r2
        L51:
            if (r1 != 0) goto L54
        L53:
            r2 = r3
        L54:
            return r2
        */
        throw new UnsupportedOperationException("Method not decompiled: c.f.k.a.e():boolean");
    }

    /* JADX WARN: Removed duplicated region for block: B:13:0x0016  */
    @Override // android.view.View.OnTouchListener
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean onTouch(android.view.View r6, android.view.MotionEvent r7) {
        /*
            r5 = this;
            boolean r0 = r5.t
            r1 = 0
            if (r0 != 0) goto L6
            return r1
        L6:
            int r0 = r7.getActionMasked()
            r2 = 1
            if (r0 == 0) goto L1a
            if (r0 == r2) goto L16
            r3 = 2
            if (r0 == r3) goto L1e
            r6 = 3
            if (r0 == r6) goto L16
            goto L7f
        L16:
            r5.d()
            goto L7f
        L1a:
            r5.r = r2
            r5.p = r1
        L1e:
            float r0 = r7.getX()
            int r3 = r6.getWidth()
            float r3 = (float) r3
            android.view.View r4 = r5.f1480g
            int r4 = r4.getWidth()
            float r4 = (float) r4
            float r0 = r5.a(r1, r0, r3, r4)
            float r7 = r7.getY()
            int r6 = r6.getHeight()
            float r6 = (float) r6
            android.view.View r3 = r5.f1480g
            int r3 = r3.getHeight()
            float r3 = (float) r3
            float r6 = r5.a(r2, r7, r6, r3)
            c.f.k.a$a r7 = r5.f1478e
            r7.f1487c = r0
            r7.f1488d = r6
            boolean r6 = r5.s
            if (r6 != 0) goto L7f
            boolean r6 = r5.e()
            if (r6 == 0) goto L7f
            java.lang.Runnable r6 = r5.f1481h
            if (r6 != 0) goto L61
            c.f.k.a$b r6 = new c.f.k.a$b
            r6.<init>()
            r5.f1481h = r6
        L61:
            r5.s = r2
            r5.q = r2
            boolean r6 = r5.p
            if (r6 != 0) goto L78
            int r6 = r5.f1485l
            if (r6 <= 0) goto L78
            android.view.View r7 = r5.f1480g
            java.lang.Runnable r0 = r5.f1481h
            long r3 = (long) r6
            java.util.WeakHashMap<android.view.View, c.f.j.i0> r6 = c.f.j.a0.a
            c.f.j.a0.d.n(r7, r0, r3)
            goto L7d
        L78:
            java.lang.Runnable r6 = r5.f1481h
            r6.run()
        L7d:
            r5.p = r2
        L7f:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: c.f.k.a.onTouch(android.view.View, android.view.MotionEvent):boolean");
    }
}
