package androidx.core.widget; 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 androidx.core.view.ViewCompat; import com.ubt.jimu.base.mvp.SingleClickListener; /* loaded from: classes.dex */ public abstract class AutoScrollHelper implements View.OnTouchListener { private static final int r = ViewConfiguration.getTapTimeout(); final View c; private Runnable d; private int g; private int h; private boolean l; boolean m; boolean n; boolean o; private boolean p; private boolean q; final ClampedScroller a = new ClampedScroller(); private final Interpolator b = new AccelerateInterpolator(); private float[] e = {0.0f, 0.0f}; private float[] f = {Float.MAX_VALUE, Float.MAX_VALUE}; private float[] i = {0.0f, 0.0f}; private float[] j = {0.0f, 0.0f}; private float[] k = {Float.MAX_VALUE, Float.MAX_VALUE}; private static class ClampedScroller { private int a; private int b; private float c; private float d; private float j; private int k; private long e = Long.MIN_VALUE; private long i = -1; private long f = 0; private int g = 0; private int h = 0; ClampedScroller() { } private float a(float f) { return ((-4.0f) * f * f) + (f * 4.0f); } public void a(int i) { this.b = i; } public void b(int i) { this.a = i; } public int c() { return this.h; } public int d() { float f = this.c; return (int) (f / Math.abs(f)); } public int e() { float f = this.d; return (int) (f / Math.abs(f)); } public boolean f() { return this.i > 0 && AnimationUtils.currentAnimationTimeMillis() > this.i + ((long) this.k); } public void g() { long currentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis(); this.k = AutoScrollHelper.a((int) (currentAnimationTimeMillis - this.e), 0, this.b); this.j = a(currentAnimationTimeMillis); this.i = currentAnimationTimeMillis; } public void h() { this.e = AnimationUtils.currentAnimationTimeMillis(); this.i = -1L; this.f = this.e; this.j = 0.5f; this.g = 0; this.h = 0; } private float a(long j) { if (j < this.e) { return 0.0f; } long j2 = this.i; if (j2 < 0 || j < j2) { return AutoScrollHelper.a((j - this.e) / this.a, 0.0f, 1.0f) * 0.5f; } long j3 = j - j2; float f = this.j; return (1.0f - f) + (f * AutoScrollHelper.a(j3 / this.k, 0.0f, 1.0f)); } public int b() { return this.g; } public void a() { if (this.f != 0) { long currentAnimationTimeMillis = AnimationUtils.currentAnimationTimeMillis(); float a = a(a(currentAnimationTimeMillis)); long j = currentAnimationTimeMillis - this.f; this.f = currentAnimationTimeMillis; float f = j * a; this.g = (int) (this.c * f); this.h = (int) (f * this.d); return; } throw new RuntimeException("Cannot compute scroll delta before calling start()"); } public void a(float f, float f2) { this.c = f; this.d = f2; } } private class ScrollAnimationRunnable implements Runnable { ScrollAnimationRunnable() { } @Override // java.lang.Runnable public void run() { AutoScrollHelper autoScrollHelper = AutoScrollHelper.this; if (autoScrollHelper.o) { if (autoScrollHelper.m) { autoScrollHelper.m = false; autoScrollHelper.a.h(); } ClampedScroller clampedScroller = AutoScrollHelper.this.a; if (clampedScroller.f() || !AutoScrollHelper.this.b()) { AutoScrollHelper.this.o = false; return; } AutoScrollHelper autoScrollHelper2 = AutoScrollHelper.this; if (autoScrollHelper2.n) { autoScrollHelper2.n = false; autoScrollHelper2.a(); } clampedScroller.a(); AutoScrollHelper.this.a(clampedScroller.b(), clampedScroller.c()); ViewCompat.a(AutoScrollHelper.this.c, this); } } } public AutoScrollHelper(View view) { this.c = view; float f = Resources.getSystem().getDisplayMetrics().density; float f2 = (int) ((1575.0f * f) + 0.5f); b(f2, f2); float f3 = (int) ((f * 315.0f) + 0.5f); c(f3, f3); d(1); a(Float.MAX_VALUE, Float.MAX_VALUE); d(0.2f, 0.2f); e(1.0f, 1.0f); c(r); f(SingleClickListener.FAST_CLICK_DELAY_TIME); e(SingleClickListener.FAST_CLICK_DELAY_TIME); } static float a(float f, float f2, float f3) { return f > f3 ? f3 : f < f2 ? f2 : f; } static int a(int i, int i2, int i3) { return i > i3 ? i3 : i < i2 ? i2 : i; } public AutoScrollHelper a(boolean z) { if (this.p && !z) { c(); } this.p = z; return this; } public abstract void a(int i, int i2); public abstract boolean a(int i); public AutoScrollHelper b(float f, float f2) { float[] fArr = this.k; fArr[0] = f / 1000.0f; fArr[1] = f2 / 1000.0f; return this; } public abstract boolean b(int i); public AutoScrollHelper c(float f, float f2) { float[] fArr = this.j; fArr[0] = f / 1000.0f; fArr[1] = f2 / 1000.0f; return this; } public AutoScrollHelper d(int i) { this.g = i; return this; } public AutoScrollHelper e(float f, float f2) { float[] fArr = this.i; fArr[0] = f / 1000.0f; fArr[1] = f2 / 1000.0f; return this; } public AutoScrollHelper f(int i) { this.a.b(i); return this; } /* JADX WARN: Code restructure failed: missing block: B:11:0x0013, code lost: if (r0 != 3) goto L20; */ @Override // android.view.View.OnTouchListener /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ public boolean onTouch(android.view.View r6, android.view.MotionEvent r7) { /* r5 = this; boolean r0 = r5.p 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 L58 L16: r5.c() goto L58 L1a: r5.n = r2 r5.l = r1 L1e: float r0 = r7.getX() int r3 = r6.getWidth() float r3 = (float) r3 android.view.View r4 = r5.c 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.c int r3 = r3.getHeight() float r3 = (float) r3 float r6 = r5.a(r2, r7, r6, r3) androidx.core.widget.AutoScrollHelper$ClampedScroller r7 = r5.a r7.a(r0, r6) boolean r6 = r5.o if (r6 != 0) goto L58 boolean r6 = r5.b() if (r6 == 0) goto L58 r5.d() L58: boolean r6 = r5.q if (r6 == 0) goto L61 boolean r6 = r5.o if (r6 == 0) goto L61 r1 = 1 L61: return r1 */ throw new UnsupportedOperationException("Method not decompiled: androidx.core.widget.AutoScrollHelper.onTouch(android.view.View, android.view.MotionEvent):boolean"); } private float f(float f, float f2) { if (f2 == 0.0f) { return 0.0f; } int i = this.g; if (i == 0 || i == 1) { if (f < f2) { if (f >= 0.0f) { return 1.0f - (f / f2); } if (this.o && this.g == 1) { return 1.0f; } } } else if (i == 2 && f < 0.0f) { return f / (-f2); } return 0.0f; } public AutoScrollHelper d(float f, float f2) { float[] fArr = this.e; fArr[0] = f; fArr[1] = f2; return this; } boolean b() { ClampedScroller clampedScroller = this.a; int e = clampedScroller.e(); int d = clampedScroller.d(); return (e != 0 && b(e)) || (d != 0 && a(d)); } public AutoScrollHelper c(int i) { this.h = i; return this; } public AutoScrollHelper e(int i) { this.a.a(i); return this; } private void c() { if (this.m) { this.o = false; } else { this.a.g(); } } private void d() { int i; if (this.d == null) { this.d = new ScrollAnimationRunnable(); } this.o = true; this.m = true; if (!this.l && (i = this.h) > 0) { ViewCompat.a(this.c, this.d, i); } else { this.d.run(); } this.l = true; } public AutoScrollHelper a(float f, float f2) { float[] fArr = this.f; fArr[0] = f; fArr[1] = f2; return this; } private float a(int i, float f, float f2, float f3) { float a = a(this.e[i], f2, this.f[i], f); if (a == 0.0f) { return 0.0f; } float f4 = this.i[i]; float f5 = this.j[i]; float f6 = this.k[i]; float f7 = f4 * f3; if (a > 0.0f) { return a(a * f7, f5, f6); } return -a((-a) * f7, f5, f6); } private float a(float f, float f2, float f3, float f4) { float interpolation; float a = a(f * f2, 0.0f, f3); float f5 = f(f2 - f4, a) - f(f4, a); if (f5 < 0.0f) { interpolation = -this.b.getInterpolation(-f5); } else { if (f5 <= 0.0f) { return 0.0f; } interpolation = this.b.getInterpolation(f5); } return a(interpolation, -1.0f, 1.0f); } void a() { long uptimeMillis = SystemClock.uptimeMillis(); MotionEvent obtain = MotionEvent.obtain(uptimeMillis, uptimeMillis, 3, 0.0f, 0.0f, 0); this.c.onTouchEvent(obtain); obtain.recycle(); } }