package X6FRs_4.IMuAHx_6.WwEq_13;

import X6FRs_4.IMuAHx_6.EuDEkJe_12.ZzDuCHW_20;
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;
/* compiled from: AutoScrollHelper.java */
/* loaded from: classes.dex */
public abstract class KQgRr5e_0 implements View.OnTouchListener {
    public static final int PGPF6hQ_2 = ViewConfiguration.getTapTimeout();

    /* renamed from: IFxWkV_5  reason: collision with root package name */
    public boolean f3119IFxWkV_5;

    /* renamed from: IMuAHx_6  reason: collision with root package name */
    public boolean f3120IMuAHx_6;
    public int KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final View f490KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Runnable f492KQgRr5e_0;

    /* renamed from: Mqv2r_3  reason: collision with root package name */
    public boolean f3121Mqv2r_3;

    /* renamed from: PGPF6hQ_2  reason: collision with other field name */
    public boolean f495PGPF6hQ_2;
    public int QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public boolean f497QxJ9d_1;

    /* renamed from: X6FRs_4  reason: collision with root package name */
    public boolean f3122X6FRs_4;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final C0044KQgRr5e_0 f489KQgRr5e_0 = new C0044KQgRr5e_0();

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final Interpolator f491KQgRr5e_0 = new AccelerateInterpolator();

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public float[] f493KQgRr5e_0 = {0.0f, 0.0f};

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public float[] f498QxJ9d_1 = {Float.MAX_VALUE, Float.MAX_VALUE};

    /* renamed from: PGPF6hQ_2  reason: collision with other field name */
    public float[] f496PGPF6hQ_2 = {0.0f, 0.0f};

    /* renamed from: Mqv2r_3  reason: collision with other field name */
    public float[] f494Mqv2r_3 = {0.0f, 0.0f};

    /* renamed from: X6FRs_4  reason: collision with other field name */
    public float[] f499X6FRs_4 = {Float.MAX_VALUE, Float.MAX_VALUE};

    /* compiled from: AutoScrollHelper.java */
    /* renamed from: X6FRs_4.IMuAHx_6.WwEq_13.KQgRr5e_0$KQgRr5e_0  reason: collision with other inner class name */
    /* loaded from: classes.dex */
    public static class C0044KQgRr5e_0 {
        public float KQgRr5e_0;

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public int f500KQgRr5e_0;
        public float PGPF6hQ_2;
        public float QxJ9d_1;

        /* renamed from: QxJ9d_1  reason: collision with other field name */
        public int f504QxJ9d_1;

        /* renamed from: X6FRs_4  reason: collision with root package name */
        public int f3124X6FRs_4;

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public long f501KQgRr5e_0 = Long.MIN_VALUE;

        /* renamed from: PGPF6hQ_2  reason: collision with other field name */
        public long f503PGPF6hQ_2 = -1;

        /* renamed from: QxJ9d_1  reason: collision with other field name */
        public long f505QxJ9d_1 = 0;

        /* renamed from: PGPF6hQ_2  reason: collision with other field name */
        public int f502PGPF6hQ_2 = 0;

        /* renamed from: Mqv2r_3  reason: collision with root package name */
        public int f3123Mqv2r_3 = 0;

        public final float KQgRr5e_0(float f) {
            return ((-4.0f) * f * f) + (f * 4.0f);
        }

        public void KQgRr5e_0(int i) {
            this.f504QxJ9d_1 = i;
        }

        public int Mqv2r_3() {
            float f = this.QxJ9d_1;
            return (int) (f / Math.abs(f));
        }

        /* renamed from: PGPF6hQ_2  reason: collision with other method in class */
        public void m325PGPF6hQ_2() {
            long currentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis();
            this.f501KQgRr5e_0 = currentAnimationTimeMillis;
            this.f503PGPF6hQ_2 = -1L;
            this.f505QxJ9d_1 = currentAnimationTimeMillis;
            this.PGPF6hQ_2 = 0.5f;
            this.f502PGPF6hQ_2 = 0;
            this.f3123Mqv2r_3 = 0;
        }

        public void QxJ9d_1(int i) {
            this.f500KQgRr5e_0 = i;
        }

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public boolean m324KQgRr5e_0() {
            return this.f503PGPF6hQ_2 > 0 && AnimationUtils.currentAnimationTimeMillis() > this.f503PGPF6hQ_2 + ((long) this.f3124X6FRs_4);
        }

        /* renamed from: QxJ9d_1  reason: collision with other method in class */
        public void m326QxJ9d_1() {
            long currentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis();
            this.f3124X6FRs_4 = KQgRr5e_0.KQgRr5e_0((int) (currentAnimationTimeMillis - this.f501KQgRr5e_0), 0, this.f504QxJ9d_1);
            this.PGPF6hQ_2 = KQgRr5e_0(currentAnimationTimeMillis);
            this.f503PGPF6hQ_2 = currentAnimationTimeMillis;
        }

        public final float KQgRr5e_0(long j) {
            if (j < this.f501KQgRr5e_0) {
                return 0.0f;
            }
            long j2 = this.f503PGPF6hQ_2;
            if (j2 >= 0 && j >= j2) {
                long j3 = j - j2;
                float f = this.PGPF6hQ_2;
                return (1.0f - f) + (f * KQgRr5e_0.KQgRr5e_0(((float) j3) / this.f3124X6FRs_4, 0.0f, 1.0f));
            }
            return KQgRr5e_0.KQgRr5e_0(((float) (j - this.f501KQgRr5e_0)) / this.f500KQgRr5e_0, 0.0f, 1.0f) * 0.5f;
        }

        public int QxJ9d_1() {
            return this.f3123Mqv2r_3;
        }

        public int PGPF6hQ_2() {
            float f = this.KQgRr5e_0;
            return (int) (f / Math.abs(f));
        }

        /* renamed from: KQgRr5e_0  reason: collision with other method in class */
        public void m323KQgRr5e_0() {
            if (this.f505QxJ9d_1 != 0) {
                long currentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis();
                float KQgRr5e_0 = KQgRr5e_0(KQgRr5e_0(currentAnimationTimeMillis));
                this.f505QxJ9d_1 = currentAnimationTimeMillis;
                float f = ((float) (currentAnimationTimeMillis - this.f505QxJ9d_1)) * KQgRr5e_0;
                this.f502PGPF6hQ_2 = (int) (this.KQgRr5e_0 * f);
                this.f3123Mqv2r_3 = (int) (f * this.QxJ9d_1);
                return;
            }
            throw new RuntimeException("Cannot compute scroll delta before calling start()");
        }

        public void KQgRr5e_0(float f, float f2) {
            this.KQgRr5e_0 = f;
            this.QxJ9d_1 = f2;
        }

        public int KQgRr5e_0() {
            return this.f502PGPF6hQ_2;
        }
    }

    /* compiled from: AutoScrollHelper.java */
    /* loaded from: classes.dex */
    public class QxJ9d_1 implements Runnable {
        public QxJ9d_1() {
        }

        @Override // java.lang.Runnable
        public void run() {
            KQgRr5e_0 kQgRr5e_0 = KQgRr5e_0.this;
            if (kQgRr5e_0.f3122X6FRs_4) {
                if (kQgRr5e_0.f495PGPF6hQ_2) {
                    kQgRr5e_0.f495PGPF6hQ_2 = false;
                    kQgRr5e_0.f489KQgRr5e_0.m325PGPF6hQ_2();
                }
                C0044KQgRr5e_0 c0044KQgRr5e_0 = KQgRr5e_0.this.f489KQgRr5e_0;
                if (!c0044KQgRr5e_0.m324KQgRr5e_0() && KQgRr5e_0.this.m320KQgRr5e_0()) {
                    KQgRr5e_0 kQgRr5e_02 = KQgRr5e_0.this;
                    if (kQgRr5e_02.f3121Mqv2r_3) {
                        kQgRr5e_02.f3121Mqv2r_3 = false;
                        kQgRr5e_02.KQgRr5e_0();
                    }
                    c0044KQgRr5e_0.m323KQgRr5e_0();
                    KQgRr5e_0.this.KQgRr5e_0(c0044KQgRr5e_0.KQgRr5e_0(), c0044KQgRr5e_0.QxJ9d_1());
                    ZzDuCHW_20.KQgRr5e_0(KQgRr5e_0.this.f490KQgRr5e_0, this);
                    return;
                }
                KQgRr5e_0.this.f3122X6FRs_4 = false;
            }
        }
    }

    public KQgRr5e_0(View view) {
        this.f490KQgRr5e_0 = view;
        float f = Resources.getSystem().getDisplayMetrics().density;
        float f2 = (int) ((1575.0f * f) + 0.5f);
        QxJ9d_1(f2, f2);
        float f3 = (int) ((f * 315.0f) + 0.5f);
        PGPF6hQ_2(f3, f3);
        QxJ9d_1(1);
        m319KQgRr5e_0(Float.MAX_VALUE, Float.MAX_VALUE);
        Mqv2r_3(0.2f, 0.2f);
        X6FRs_4(1.0f, 1.0f);
        KQgRr5e_0(PGPF6hQ_2);
        Mqv2r_3(500);
        PGPF6hQ_2(500);
    }

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

    public static int KQgRr5e_0(int i, int i2, int i3) {
        return i > i3 ? i3 : i < i2 ? i2 : i;
    }

    public KQgRr5e_0 KQgRr5e_0(boolean z) {
        if (this.f3119IFxWkV_5 && !z) {
            QxJ9d_1();
        }
        this.f3119IFxWkV_5 = z;
        return this;
    }

    public abstract void KQgRr5e_0(int i, int i2);

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public abstract boolean m321KQgRr5e_0(int i);

    public KQgRr5e_0 Mqv2r_3(float f, float f2) {
        float[] fArr = this.f493KQgRr5e_0;
        fArr[0] = f;
        fArr[1] = f2;
        return this;
    }

    public KQgRr5e_0 PGPF6hQ_2(float f, float f2) {
        float[] fArr = this.f494Mqv2r_3;
        fArr[0] = f / 1000.0f;
        fArr[1] = f2 / 1000.0f;
        return this;
    }

    public KQgRr5e_0 QxJ9d_1(float f, float f2) {
        float[] fArr = this.f499X6FRs_4;
        fArr[0] = f / 1000.0f;
        fArr[1] = f2 / 1000.0f;
        return this;
    }

    /* renamed from: QxJ9d_1  reason: collision with other method in class */
    public abstract boolean m322QxJ9d_1(int i);

    public KQgRr5e_0 X6FRs_4(float f, float f2) {
        float[] fArr = this.f496PGPF6hQ_2;
        fArr[0] = f / 1000.0f;
        fArr[1] = f2 / 1000.0f;
        return this;
    }

    /* JADX WARN: Code restructure failed: missing block: B:11:0x0013, code lost:
        if (r0 != 3) goto L12;
     */
    @Override // android.view.View.OnTouchListener
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public boolean onTouch(View view, MotionEvent motionEvent) {
        if (!this.f3119IFxWkV_5) {
            return false;
        }
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked != 0) {
            if (actionMasked != 1) {
                if (actionMasked != 2) {
                }
            }
            QxJ9d_1();
            return this.f3120IMuAHx_6 && this.f3122X6FRs_4;
        }
        this.f3121Mqv2r_3 = true;
        this.f497QxJ9d_1 = false;
        this.f489KQgRr5e_0.KQgRr5e_0(KQgRr5e_0(0, motionEvent.getX(), view.getWidth(), this.f490KQgRr5e_0.getWidth()), KQgRr5e_0(1, motionEvent.getY(), view.getHeight(), this.f490KQgRr5e_0.getHeight()));
        if (!this.f3122X6FRs_4 && m320KQgRr5e_0()) {
            PGPF6hQ_2();
        }
        if (this.f3120IMuAHx_6) {
            return false;
        }
    }

    public KQgRr5e_0 Mqv2r_3(int i) {
        this.f489KQgRr5e_0.QxJ9d_1(i);
        return this;
    }

    public KQgRr5e_0 PGPF6hQ_2(int i) {
        this.f489KQgRr5e_0.KQgRr5e_0(i);
        return this;
    }

    public KQgRr5e_0 QxJ9d_1(int i) {
        this.KQgRr5e_0 = i;
        return this;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public KQgRr5e_0 m319KQgRr5e_0(float f, float f2) {
        float[] fArr = this.f498QxJ9d_1;
        fArr[0] = f;
        fArr[1] = f2;
        return this;
    }

    public final void PGPF6hQ_2() {
        int i;
        if (this.f492KQgRr5e_0 == null) {
            this.f492KQgRr5e_0 = new QxJ9d_1();
        }
        this.f3122X6FRs_4 = true;
        this.f495PGPF6hQ_2 = true;
        if (!this.f497QxJ9d_1 && (i = this.QxJ9d_1) > 0) {
            ZzDuCHW_20.KQgRr5e_0(this.f490KQgRr5e_0, this.f492KQgRr5e_0, i);
        } else {
            this.f492KQgRr5e_0.run();
        }
        this.f497QxJ9d_1 = true;
    }

    public final void QxJ9d_1() {
        if (this.f495PGPF6hQ_2) {
            this.f3122X6FRs_4 = false;
        } else {
            this.f489KQgRr5e_0.m326QxJ9d_1();
        }
    }

    public KQgRr5e_0 KQgRr5e_0(int i) {
        this.QxJ9d_1 = i;
        return this;
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public boolean m320KQgRr5e_0() {
        C0044KQgRr5e_0 c0044KQgRr5e_0 = this.f489KQgRr5e_0;
        int Mqv2r_32 = c0044KQgRr5e_0.Mqv2r_3();
        int PGPF6hQ_22 = c0044KQgRr5e_0.PGPF6hQ_2();
        return (Mqv2r_32 != 0 && m322QxJ9d_1(Mqv2r_32)) || (PGPF6hQ_22 != 0 && m321KQgRr5e_0(PGPF6hQ_22));
    }

    public final float KQgRr5e_0(int i, float f, float f2, float f3) {
        float KQgRr5e_0 = KQgRr5e_0(this.f493KQgRr5e_0[i], f2, this.f498QxJ9d_1[i], f);
        if (KQgRr5e_0 == 0.0f) {
            return 0.0f;
        }
        float f4 = this.f496PGPF6hQ_2[i];
        float f5 = this.f494Mqv2r_3[i];
        float f6 = this.f499X6FRs_4[i];
        float f7 = f4 * f3;
        if (KQgRr5e_0 > 0.0f) {
            return KQgRr5e_0(KQgRr5e_0 * f7, f5, f6);
        }
        return -KQgRr5e_0((-KQgRr5e_0) * f7, f5, f6);
    }

    public final float KQgRr5e_0(float f, float f2, float f3, float f4) {
        float interpolation;
        float KQgRr5e_0 = KQgRr5e_0(f * f2, 0.0f, f3);
        float KQgRr5e_02 = KQgRr5e_0(f2 - f4, KQgRr5e_0) - KQgRr5e_0(f4, KQgRr5e_0);
        if (KQgRr5e_02 < 0.0f) {
            interpolation = -this.f491KQgRr5e_0.getInterpolation(-KQgRr5e_02);
        } else if (KQgRr5e_02 <= 0.0f) {
            return 0.0f;
        } else {
            interpolation = this.f491KQgRr5e_0.getInterpolation(KQgRr5e_02);
        }
        return KQgRr5e_0(interpolation, -1.0f, 1.0f);
    }

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

    public void KQgRr5e_0() {
        long uptimeMillis = SystemClock.uptimeMillis();
        MotionEvent obtain = MotionEvent.obtain(uptimeMillis, uptimeMillis, 3, 0.0f, 0.0f, 0);
        this.f490KQgRr5e_0.onTouchEvent(obtain);
        obtain.recycle();
    }
}
