package d.h.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 d.h.j.y;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final int f2803f = ViewConfiguration.getTapTimeout();
    public boolean A;
    public boolean B;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final C0036a f2804m;

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public boolean f2815x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public boolean f2816y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public boolean f2817z;

    /* JADX INFO: renamed from: d.h.k.a$a, reason: collision with other inner class name */
    public static class C0036a {
        public int a;

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

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

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

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

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

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

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

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

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

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

        public final float a(long j2) {
            if (j2 < this.f2821e) {
                return 0.0f;
            }
            long j3 = this.f2825i;
            if (j3 < 0 || j2 < j3) {
                return a.b((j2 - r0) / this.a, 0.0f, 1.0f) * 0.5f;
            }
            float f2 = this.f2826j;
            return (a.b((j2 - j3) / this.f2827k, 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.A) {
                if (aVar.f2816y) {
                    aVar.f2816y = false;
                    C0036a c0036a = aVar.f2804m;
                    Objects.requireNonNull(c0036a);
                    long jCurrentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis();
                    c0036a.f2821e = jCurrentAnimationTimeMillis;
                    c0036a.f2825i = -1L;
                    c0036a.f2822f = jCurrentAnimationTimeMillis;
                    c0036a.f2826j = 0.5f;
                    c0036a.f2823g = 0;
                    c0036a.f2824h = 0;
                }
                C0036a c0036a2 = a.this.f2804m;
                if ((c0036a2.f2825i > 0 && AnimationUtils.currentAnimationTimeMillis() > c0036a2.f2825i + ((long) c0036a2.f2827k)) || !a.this.e()) {
                    a.this.A = false;
                    return;
                }
                a aVar2 = a.this;
                if (aVar2.f2817z) {
                    aVar2.f2817z = false;
                    Objects.requireNonNull(aVar2);
                    long jUptimeMillis = SystemClock.uptimeMillis();
                    MotionEvent motionEventObtain = MotionEvent.obtain(jUptimeMillis, jUptimeMillis, 3, 0.0f, 0.0f, 0);
                    aVar2.f2806o.onTouchEvent(motionEventObtain);
                    motionEventObtain.recycle();
                }
                if (c0036a2.f2822f == 0) {
                    throw new RuntimeException("Cannot compute scroll delta before calling start()");
                }
                long jCurrentAnimationTimeMillis2 = AnimationUtils.currentAnimationTimeMillis();
                float fA = c0036a2.a(jCurrentAnimationTimeMillis2);
                long j2 = jCurrentAnimationTimeMillis2 - c0036a2.f2822f;
                c0036a2.f2822f = jCurrentAnimationTimeMillis2;
                float f2 = j2 * ((fA * 4.0f) + ((-4.0f) * fA * fA));
                c0036a2.f2823g = (int) (c0036a2.f2819c * f2);
                int i2 = (int) (f2 * c0036a2.f2820d);
                c0036a2.f2824h = i2;
                i.b(((h) a.this).C, i2);
                View view = a.this.f2806o;
                AtomicInteger atomicInteger = y.a;
                y.c.m(view, this);
            }
        }
    }

    public a(View view) {
        C0036a c0036a = new C0036a();
        this.f2804m = c0036a;
        this.f2805n = new AccelerateInterpolator();
        this.f2808q = new float[]{0.0f, 0.0f};
        this.f2809r = new float[]{Float.MAX_VALUE, Float.MAX_VALUE};
        this.f2812u = new float[]{0.0f, 0.0f};
        this.f2813v = new float[]{0.0f, 0.0f};
        this.f2814w = new float[]{Float.MAX_VALUE, Float.MAX_VALUE};
        this.f2806o = view;
        float f2 = Resources.getSystem().getDisplayMetrics().density;
        float[] fArr = this.f2814w;
        float f3 = ((int) ((1575.0f * f2) + 0.5f)) / 1000.0f;
        fArr[0] = f3;
        fArr[1] = f3;
        float[] fArr2 = this.f2813v;
        float f4 = ((int) ((f2 * 315.0f) + 0.5f)) / 1000.0f;
        fArr2[0] = f4;
        fArr2[1] = f4;
        this.f2810s = 1;
        float[] fArr3 = this.f2809r;
        fArr3[0] = Float.MAX_VALUE;
        fArr3[1] = Float.MAX_VALUE;
        float[] fArr4 = this.f2808q;
        fArr4[0] = 0.2f;
        fArr4[1] = 0.2f;
        float[] fArr5 = this.f2812u;
        fArr5[0] = 0.001f;
        fArr5[1] = 0.001f;
        this.f2811t = f2803f;
        c0036a.a = 500;
        c0036a.f2818b = 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.f2808q
            r0 = r0[r4]
            float[] r1 = r3.f2809r
            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.f2805n
            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.f2805n
            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.f2812u
            r0 = r0[r4]
            float[] r1 = r3.f2813v
            r1 = r1[r4]
            float[] r2 = r3.f2814w
            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: d.h.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.f2810s;
        if (i2 == 0 || i2 == 1) {
            if (f2 < f3) {
                if (f2 >= 0.0f) {
                    return 1.0f - (f2 / f3);
                }
                if (this.A && 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.f2816y) {
            this.A = false;
            return;
        }
        C0036a c0036a = this.f2804m;
        Objects.requireNonNull(c0036a);
        long jCurrentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis();
        int i3 = (int) (jCurrentAnimationTimeMillis - c0036a.f2821e);
        int i4 = c0036a.f2818b;
        if (i3 > i4) {
            i2 = i4;
        } else if (i3 >= 0) {
            i2 = i3;
        }
        c0036a.f2827k = i2;
        c0036a.f2826j = c0036a.a(jCurrentAnimationTimeMillis);
        c0036a.f2825i = 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;
            d.h.k.a$a r0 = r9.f2804m
            float r1 = r0.f2820d
            float r2 = java.lang.Math.abs(r1)
            float r1 = r1 / r2
            int r1 = (int) r1
            float r0 = r0.f2819c
            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
            d.h.k.h r4 = (d.h.k.h) r4
            android.widget.ListView r4 = r4.C
            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: d.h.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.B
            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.f2817z = r2
            r5.f2815x = r1
        L1e:
            float r0 = r7.getX()
            int r3 = r6.getWidth()
            float r3 = (float) r3
            android.view.View r4 = r5.f2806o
            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.f2806o
            int r3 = r3.getHeight()
            float r3 = (float) r3
            float r6 = r5.a(r2, r7, r6, r3)
            d.h.k.a$a r7 = r5.f2804m
            r7.f2819c = r0
            r7.f2820d = r6
            boolean r6 = r5.A
            if (r6 != 0) goto L7f
            boolean r6 = r5.e()
            if (r6 == 0) goto L7f
            java.lang.Runnable r6 = r5.f2807p
            if (r6 != 0) goto L61
            d.h.k.a$b r6 = new d.h.k.a$b
            r6.<init>()
            r5.f2807p = r6
        L61:
            r5.A = r2
            r5.f2816y = r2
            boolean r6 = r5.f2815x
            if (r6 != 0) goto L78
            int r6 = r5.f2811t
            if (r6 <= 0) goto L78
            android.view.View r7 = r5.f2806o
            java.lang.Runnable r0 = r5.f2807p
            long r3 = (long) r6
            java.util.concurrent.atomic.AtomicInteger r6 = d.h.j.y.a
            d.h.j.y.c.n(r7, r0, r3)
            goto L7d
        L78:
            java.lang.Runnable r6 = r5.f2807p
            r6.run()
        L7d:
            r5.f2815x = r2
        L7f:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: d.h.k.a.onTouch(android.view.View, android.view.MotionEvent):boolean");
    }
}
