package ῲ.ᨨ.㳳;

import android.content.res.Resources;
import android.os.Build;
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 android.widget.ListView;
import ῲ.ᨨ.ᨨ.C1729;

/* renamed from: ῲ.ᨨ.㳳.K  reason: contains not printable characters */
/* compiled from: AutoScrollHelper */
public abstract class AbstractView$OnTouchListenerC1837 implements View.OnTouchListener {

    /* renamed from: ݜ  reason: contains not printable characters */
    public static final int f6228 = ViewConfiguration.getTapTimeout();

    /* renamed from: ʬ  reason: contains not printable characters */
    public final Interpolator f6229 = new AccelerateInterpolator();

    /* renamed from: Ԕ  reason: contains not printable characters */
    public boolean f6230;

    /* renamed from: ؿ  reason: contains not printable characters */
    public boolean f6231;

    /* renamed from: ඓ  reason: contains not printable characters */
    public Runnable f6232;

    /* renamed from: ᓣ  reason: contains not printable characters */
    public boolean f6233;

    /* renamed from: ᕣ  reason: contains not printable characters */
    public float[] f6234 = {0.0f, 0.0f};

    /* renamed from: ᨨ  reason: contains not printable characters */
    public int f6235;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final C1839 f6236 = new C1839();

    /* renamed from: ⁱ  reason: contains not printable characters */
    public float[] f6237 = {Float.MAX_VALUE, Float.MAX_VALUE};

    /* renamed from: 㑃  reason: contains not printable characters */
    public float[] f6238 = {Float.MAX_VALUE, Float.MAX_VALUE};

    /* renamed from: 㗗  reason: contains not printable characters */
    public boolean f6239;

    /* renamed from: 㗽  reason: contains not printable characters */
    public boolean f6240;

    /* renamed from: 㳳  reason: contains not printable characters */
    public float[] f6241 = {0.0f, 0.0f};

    /* renamed from: 㴹  reason: contains not printable characters */
    public float[] f6242 = {0.0f, 0.0f};

    /* renamed from: 㸾  reason: contains not printable characters */
    public final View f6243;

    /* renamed from: 㿎  reason: contains not printable characters */
    public int f6244;

    /* renamed from: 䁗  reason: contains not printable characters */
    public boolean f6245;

    /* renamed from: ῲ.ᨨ.㳳.K$ῲ  reason: contains not printable characters */
    /* compiled from: AutoScrollHelper */
    public class RunnableC1838 implements Runnable {
        public RunnableC1838() {
        }

        public void run() {
            AbstractView$OnTouchListenerC1837 k = AbstractView$OnTouchListenerC1837.this;
            if (k.f6231) {
                if (k.f6230) {
                    k.f6230 = false;
                    k.f6236.m4736();
                }
                C1839 k2 = AbstractView$OnTouchListenerC1837.this.f6236;
                if ((k2.f6250 > 0 && AnimationUtils.currentAnimationTimeMillis() > k2.f6250 + ((long) k2.f6249)) || !AbstractView$OnTouchListenerC1837.this.m4731()) {
                    AbstractView$OnTouchListenerC1837.this.f6231 = false;
                    return;
                }
                AbstractView$OnTouchListenerC1837 k3 = AbstractView$OnTouchListenerC1837.this;
                if (k3.f6239) {
                    k3.f6239 = false;
                    k3.m4735();
                }
                if (k2.f6255 != 0) {
                    long currentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis();
                    float r3 = k2.m4737(currentAnimationTimeMillis);
                    k2.f6255 = currentAnimationTimeMillis;
                    float f = ((float) (currentAnimationTimeMillis - k2.f6255)) * ((r3 * 4.0f) + (-4.0f * r3 * r3));
                    k2.f6252 = (int) (k2.f6247 * f);
                    k2.f6257 = (int) (f * k2.f6256);
                    int i = k2.f6252;
                    int i2 = k2.f6257;
                    ListView listView = ((C1833) AbstractView$OnTouchListenerC1837.this).f6226;
                    int i3 = Build.VERSION.SDK_INT;
                    listView.scrollListBy(i2);
                    C1729.m4479(AbstractView$OnTouchListenerC1837.this.f6243, this);
                    return;
                }
                throw new RuntimeException("Cannot compute scroll delta before calling start()");
            }
        }
    }

    public AbstractView$OnTouchListenerC1837(View view) {
        this.f6243 = view;
        float f = Resources.getSystem().getDisplayMetrics().density;
        float[] fArr = this.f6238;
        float f2 = ((float) ((int) ((1575.0f * f) + 0.5f))) / 1000.0f;
        fArr[0] = f2;
        fArr[1] = f2;
        float[] fArr2 = this.f6234;
        float f3 = ((float) ((int) ((f * 315.0f) + 0.5f))) / 1000.0f;
        fArr2[0] = f3;
        fArr2[1] = f3;
        this.f6244 = 1;
        float[] fArr3 = this.f6237;
        fArr3[0] = Float.MAX_VALUE;
        fArr3[1] = Float.MAX_VALUE;
        float[] fArr4 = this.f6242;
        fArr4[0] = 0.2f;
        fArr4[1] = 0.2f;
        float[] fArr5 = this.f6241;
        fArr5[0] = 0.001f;
        fArr5[1] = 0.001f;
        this.f6235 = f6228;
        C1839 k = this.f6236;
        k.f6253 = 500;
        k.f6251 = 500;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static float m4729(float f, float f2, float f3) {
        return f > f3 ? f3 : f < f2 ? f2 : f;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static int m4730(int i, int i2, int i3) {
        return i > i3 ? i3 : i < i2 ? i2 : i;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:9:0x0013, code lost:
        if (r0 != 3) goto L_0x0086;
     */
    public boolean onTouch(View view, MotionEvent motionEvent) {
        int i;
        if (!this.f6233) {
            return false;
        }
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked != 0) {
            if (actionMasked != 1) {
                if (actionMasked != 2) {
                }
            }
            if (this.f6230) {
                this.f6231 = false;
            } else {
                this.f6236.m4738();
            }
            if (!this.f6240 && this.f6231) {
                return true;
            }
        }
        this.f6239 = true;
        this.f6245 = false;
        float r0 = m4733(0, motionEvent.getX(), (float) view.getWidth(), (float) this.f6243.getWidth());
        float r6 = m4733(1, motionEvent.getY(), (float) view.getHeight(), (float) this.f6243.getHeight());
        C1839 k = this.f6236;
        k.f6247 = r0;
        k.f6256 = r6;
        if (!this.f6231 && m4731()) {
            if (this.f6232 == null) {
                this.f6232 = new RunnableC1838();
            }
            this.f6231 = true;
            this.f6230 = true;
            if (this.f6245 || (i = this.f6235) <= 0) {
                this.f6232.run();
            } else {
                C1729.m4480(this.f6243, this.f6232, (long) i);
            }
            this.f6245 = true;
        }
        return !this.f6240 ? false : false;
    }

    /* JADX WARNING: Removed duplicated region for block: B:19:? A[RETURN, SYNTHETIC] */
    /* renamed from: ῲ  reason: contains not printable characters */
    public boolean m4731() {
        boolean z;
        C1839 k = this.f6236;
        float f = k.f6256;
        int abs = (int) (f / Math.abs(f));
        float f2 = k.f6247;
        int abs2 = (int) (f2 / Math.abs(f2));
        if (abs != 0) {
            ListView listView = ((C1833) this).f6226;
            int count = listView.getCount();
            if (count != 0) {
                int childCount = listView.getChildCount();
                int firstVisiblePosition = listView.getFirstVisiblePosition();
                int i = firstVisiblePosition + childCount;
                if (abs <= 0 ? !(abs >= 0 || (firstVisiblePosition <= 0 && listView.getChildAt(0).getTop() >= 0)) : !(i >= count && listView.getChildAt(childCount - 1).getBottom() <= listView.getHeight())) {
                    z = true;
                    if (z) {
                        return true;
                    }
                }
            }
            z = false;
            if (z) {
            }
        }
        if (abs2 != 0) {
            C1833 r0 = (C1833) this;
        }
        return false;
    }

    /* renamed from: K  reason: contains not printable characters */
    public AbstractView$OnTouchListenerC1837 m4734(boolean z) {
        if (this.f6233 && !z) {
            if (this.f6230) {
                this.f6231 = false;
            } else {
                this.f6236.m4738();
            }
        }
        this.f6233 = z;
        return this;
    }

    /* renamed from: ῲ.ᨨ.㳳.K$K  reason: contains not printable characters */
    /* compiled from: AutoScrollHelper */
    public static class C1839 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public float f6247;

        /* renamed from: ඓ  reason: contains not printable characters */
        public long f6248 = Long.MIN_VALUE;

        /* renamed from: ᕣ  reason: contains not printable characters */
        public int f6249;

        /* renamed from: ᨨ  reason: contains not printable characters */
        public long f6250 = -1;

        /* renamed from: ῲ  reason: contains not printable characters */
        public int f6251;

        /* renamed from: ⁱ  reason: contains not printable characters */
        public int f6252 = 0;

        /* renamed from: K  reason: contains not printable characters */
        public int f6253;

        /* renamed from: 㳳  reason: contains not printable characters */
        public float f6254;

        /* renamed from: 㴹  reason: contains not printable characters */
        public long f6255 = 0;

        /* renamed from: 㸾  reason: contains not printable characters */
        public float f6256;

        /* renamed from: 㿎  reason: contains not printable characters */
        public int f6257 = 0;

        /* renamed from: ῲ  reason: contains not printable characters */
        public void m4736() {
            this.f6248 = AnimationUtils.currentAnimationTimeMillis();
            this.f6250 = -1;
            this.f6255 = this.f6248;
            this.f6254 = 0.5f;
            this.f6252 = 0;
            this.f6257 = 0;
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m4738() {
            long currentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis();
            this.f6249 = AbstractView$OnTouchListenerC1837.m4730((int) (currentAnimationTimeMillis - this.f6248), 0, this.f6251);
            this.f6254 = m4737(currentAnimationTimeMillis);
            this.f6250 = currentAnimationTimeMillis;
        }

        /* renamed from: K  reason: contains not printable characters */
        public final float m4737(long j) {
            if (j < this.f6248) {
                return 0.0f;
            }
            long j2 = this.f6250;
            if (j2 < 0 || j < j2) {
                return AbstractView$OnTouchListenerC1837.m4729(((float) (j - this.f6248)) / ((float) this.f6253), 0.0f, 1.0f) * 0.5f;
            }
            long j3 = j - j2;
            float f = this.f6254;
            return (AbstractView$OnTouchListenerC1837.m4729(((float) j3) / ((float) this.f6249), 0.0f, 1.0f) * f) + (1.0f - f);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:10:0x003e A[RETURN] */
    /* JADX WARNING: Removed duplicated region for block: B:11:0x003f  */
    /* renamed from: K  reason: contains not printable characters */
    public final float m4733(int i, float f, float f2, float f3) {
        float f4;
        int i2;
        float f5;
        float r0 = m4729(this.f6242[i] * f2, 0.0f, this.f6237[i]);
        float r5 = m4732(f2 - f, r0) - m4732(f, r0);
        if (r5 < 0.0f) {
            f5 = -this.f6229.getInterpolation(-r5);
        } else if (r5 > 0.0f) {
            f5 = this.f6229.getInterpolation(r5);
        } else {
            f4 = 0.0f;
            i2 = (f4 > 0.0f ? 1 : (f4 == 0.0f ? 0 : -1));
            if (i2 != 0) {
                return 0.0f;
            }
            float f6 = this.f6241[i];
            float f7 = this.f6234[i];
            float f8 = this.f6238[i];
            float f9 = f6 * f3;
            if (i2 > 0) {
                return m4729(f4 * f9, f7, f8);
            }
            return -m4729((-f4) * f9, f7, f8);
        }
        f4 = m4729(f5, -1.0f, 1.0f);
        i2 = (f4 > 0.0f ? 1 : (f4 == 0.0f ? 0 : -1));
        if (i2 != 0) {
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final float m4732(float f, float f2) {
        if (f2 == 0.0f) {
            return 0.0f;
        }
        int i = this.f6244;
        if (i == 0 || i == 1) {
            if (f < f2) {
                if (f >= 0.0f) {
                    return 1.0f - (f / f2);
                }
                return (!this.f6231 || this.f6244 != 1) ? 0.0f : 1.0f;
            }
        } else if (i == 2 && f < 0.0f) {
            return f / (-f2);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m4735() {
        long uptimeMillis = SystemClock.uptimeMillis();
        MotionEvent obtain = MotionEvent.obtain(uptimeMillis, uptimeMillis, 3, 0.0f, 0.0f, 0);
        this.f6243.onTouchEvent(obtain);
        obtain.recycle();
    }
}
