package c.e.j;

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.e.i.l;
import c.e.i.q;
import java.util.Objects;
import java.util.WeakHashMap;

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

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final C0069a f5332b;

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public float[] f5340j;
    public float[] k;
    public float[] l;
    public boolean m;
    public boolean n;
    public boolean o;
    public boolean p;
    public boolean q;

    /* JADX INFO: renamed from: c.e.j.a$a, reason: collision with other inner class name */
    public static class C0069a {

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

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

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

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

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

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

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

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

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

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

        public final float a(long j2) {
            if (j2 < this.f5345e) {
                return 0.0f;
            }
            long j3 = this.f5349i;
            if (j3 < 0 || j2 < j3) {
                return a.b((j2 - r0) / this.f5341a, 0.0f, 1.0f) * 0.5f;
            }
            float f2 = this.f5350j;
            return (a.b((j2 - j3) / this.k, 0.0f, 1.0f) * f2) + (1.0f - f2);
        }
    }

    public class b implements Runnable {
        public b() {
        }

        @Override // java.lang.Runnable
        public void run() {
            a aVar = a.this;
            if (aVar.p) {
                if (aVar.n) {
                    aVar.n = false;
                    C0069a c0069a = aVar.f5332b;
                    Objects.requireNonNull(c0069a);
                    long jCurrentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis();
                    c0069a.f5345e = jCurrentAnimationTimeMillis;
                    c0069a.f5349i = -1L;
                    c0069a.f5346f = jCurrentAnimationTimeMillis;
                    c0069a.f5350j = 0.5f;
                    c0069a.f5347g = 0;
                    c0069a.f5348h = 0;
                }
                C0069a c0069a2 = a.this.f5332b;
                if ((c0069a2.f5349i > 0 && AnimationUtils.currentAnimationTimeMillis() > c0069a2.f5349i + ((long) c0069a2.k)) || !a.this.e()) {
                    a.this.p = false;
                    return;
                }
                a aVar2 = a.this;
                if (aVar2.o) {
                    aVar2.o = false;
                    long jUptimeMillis = SystemClock.uptimeMillis();
                    MotionEvent motionEventObtain = MotionEvent.obtain(jUptimeMillis, jUptimeMillis, 3, 0.0f, 0.0f, 0);
                    aVar2.f5334d.onTouchEvent(motionEventObtain);
                    motionEventObtain.recycle();
                }
                if (c0069a2.f5346f == 0) {
                    throw new RuntimeException("Cannot compute scroll delta before calling start()");
                }
                long jCurrentAnimationTimeMillis2 = AnimationUtils.currentAnimationTimeMillis();
                float fA = c0069a2.a(jCurrentAnimationTimeMillis2);
                long j2 = jCurrentAnimationTimeMillis2 - c0069a2.f5346f;
                c0069a2.f5346f = jCurrentAnimationTimeMillis2;
                float f2 = j2 * ((fA * 4.0f) + ((-4.0f) * fA * fA));
                c0069a2.f5347g = (int) (c0069a2.f5343c * f2);
                int i2 = (int) (f2 * c0069a2.f5344d);
                c0069a2.f5348h = i2;
                ((c) a.this).r.scrollListBy(i2);
                View view = a.this.f5334d;
                WeakHashMap<View, q> weakHashMap = l.f5278a;
                view.postOnAnimation(this);
            }
        }
    }

    public a(View view) {
        C0069a c0069a = new C0069a();
        this.f5332b = c0069a;
        this.f5333c = new AccelerateInterpolator();
        this.f5336f = new float[]{0.0f, 0.0f};
        this.f5337g = new float[]{Float.MAX_VALUE, Float.MAX_VALUE};
        this.f5340j = new float[]{0.0f, 0.0f};
        this.k = new float[]{0.0f, 0.0f};
        this.l = new float[]{Float.MAX_VALUE, Float.MAX_VALUE};
        this.f5334d = view;
        float f2 = Resources.getSystem().getDisplayMetrics().density;
        float[] fArr = this.l;
        float f3 = ((int) ((1575.0f * f2) + 0.5f)) / 1000.0f;
        fArr[0] = f3;
        fArr[1] = f3;
        float[] fArr2 = this.k;
        float f4 = ((int) ((f2 * 315.0f) + 0.5f)) / 1000.0f;
        fArr2[0] = f4;
        fArr2[1] = f4;
        this.f5338h = 1;
        float[] fArr3 = this.f5337g;
        fArr3[0] = Float.MAX_VALUE;
        fArr3[1] = Float.MAX_VALUE;
        float[] fArr4 = this.f5336f;
        fArr4[0] = 0.2f;
        fArr4[1] = 0.2f;
        float[] fArr5 = this.f5340j;
        fArr5[0] = 0.001f;
        fArr5[1] = 0.001f;
        this.f5339i = f5331a;
        c0069a.f5341a = 500;
        c0069a.f5342b = 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.f5336f
            r0 = r0[r4]
            float[] r1 = r3.f5337g
            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.f5333c
            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.f5333c
            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.f5340j
            r0 = r0[r4]
            float[] r1 = r3.k
            r1 = r1[r4]
            float[] r2 = r3.l
            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.e.j.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.f5338h;
        if (i2 == 0 || i2 == 1) {
            if (f2 < f3) {
                if (f2 >= 0.0f) {
                    return 1.0f - (f2 / f3);
                }
                if (this.p && 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.n) {
            this.p = false;
            return;
        }
        C0069a c0069a = this.f5332b;
        Objects.requireNonNull(c0069a);
        long jCurrentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis();
        int i3 = (int) (jCurrentAnimationTimeMillis - c0069a.f5345e);
        int i4 = c0069a.f5342b;
        if (i3 > i4) {
            i2 = i4;
        } else if (i3 >= 0) {
            i2 = i3;
        }
        c0069a.k = i2;
        c0069a.f5350j = c0069a.a(jCurrentAnimationTimeMillis);
        c0069a.f5349i = 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.e.j.a$a r0 = r9.f5332b
            float r1 = r0.f5344d
            float r2 = java.lang.Math.abs(r1)
            float r1 = r1 / r2
            int r1 = (int) r1
            float r0 = r0.f5343c
            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.e.j.c r4 = (c.e.j.c) r4
            android.widget.ListView r4 = r4.r
            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.e.j.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.q
            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.o = r2
            r5.m = r1
        L1e:
            float r0 = r7.getX()
            int r3 = r6.getWidth()
            float r3 = (float) r3
            android.view.View r4 = r5.f5334d
            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.f5334d
            int r3 = r3.getHeight()
            float r3 = (float) r3
            float r6 = r5.a(r2, r7, r6, r3)
            c.e.j.a$a r7 = r5.f5332b
            r7.f5343c = r0
            r7.f5344d = r6
            boolean r6 = r5.p
            if (r6 != 0) goto L7f
            boolean r6 = r5.e()
            if (r6 == 0) goto L7f
            java.lang.Runnable r6 = r5.f5335e
            if (r6 != 0) goto L61
            c.e.j.a$b r6 = new c.e.j.a$b
            r6.<init>()
            r5.f5335e = r6
        L61:
            r5.p = r2
            r5.n = r2
            boolean r6 = r5.m
            if (r6 != 0) goto L78
            int r6 = r5.f5339i
            if (r6 <= 0) goto L78
            android.view.View r7 = r5.f5334d
            java.lang.Runnable r0 = r5.f5335e
            long r3 = (long) r6
            java.util.WeakHashMap<android.view.View, c.e.i.q> r6 = c.e.i.l.f5278a
            r7.postOnAnimationDelayed(r0, r3)
            goto L7d
        L78:
            java.lang.Runnable r6 = r5.f5335e
            r6.run()
        L7d:
            r5.m = r2
        L7f:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.j.a.onTouch(android.view.View, android.view.MotionEvent):boolean");
    }
}
