package o; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.graphics.drawable.StateListDrawable; import android.view.MotionEvent; import androidx.core.view.ViewCompat; import androidx.recyclerview.widget.RecyclerView; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import java.util.ArrayList; import java.util.List; /* loaded from: classes.dex */ public final class Jfh extends RecyclerView.ZqN implements RecyclerView.jNh { private final RecyclerView.dAO A; private float B; private final int C; private final int D; private final int E; int a; int b; int c; final int g; RecyclerView h; final ValueAnimator i; int l; final Drawable m; int n; /* renamed from: o, reason: collision with root package name */ final StateListDrawable f8228o; private float p; private final Runnable t; private final int v; private final StateListDrawable w; private final int x; private final Drawable y; private static final int[] s = {android.R.attr.state_pressed}; private static final int[] r = new int[0]; int j = 0; int f = 0; boolean d = false; boolean e = false; int k = 0; private int q = 0; private final int[] z = new int[2]; private final int[] u = new int[2]; @Override // androidx.recyclerview.widget.RecyclerView.jNh public final void b(boolean z) { } public Jfh(RecyclerView recyclerView, StateListDrawable stateListDrawable, Drawable drawable, StateListDrawable stateListDrawable2, Drawable drawable2, int i, int i2, int i3) { ValueAnimator ofFloat = ValueAnimator.ofFloat(BitmapDescriptorFactory.HUE_RED, 1.0f); this.i = ofFloat; this.c = 0; Runnable runnable = new Runnable(this) { // from class: o.Jfh.4 final Jfh b; { this.b = this; } @Override // java.lang.Runnable public final void run() { Jfh jfh = this.b; int i4 = jfh.c; if (i4 == 1) { jfh.i.cancel(); } else if (i4 != 2) { return; } jfh.c = 3; ValueAnimator valueAnimator = jfh.i; valueAnimator.setFloatValues(((Float) valueAnimator.getAnimatedValue()).floatValue(), BitmapDescriptorFactory.HUE_RED); jfh.i.setDuration(500L); jfh.i.start(); } }; this.t = runnable; RecyclerView.dAO dao = new RecyclerView.dAO(this) { // from class: o.Jfh.2 final Jfh d; { this.d = this; } @Override // androidx.recyclerview.widget.RecyclerView.dAO public final void onScrolled(RecyclerView recyclerView2, int i4, int i5) { Jfh jfh = this.d; int computeHorizontalScrollOffset = recyclerView2.computeHorizontalScrollOffset(); int computeVerticalScrollOffset = recyclerView2.computeVerticalScrollOffset(); int computeVerticalScrollRange = jfh.h.computeVerticalScrollRange(); int i6 = jfh.f; jfh.d = computeVerticalScrollRange - i6 > 0 && i6 >= jfh.g; int computeHorizontalScrollRange = jfh.h.computeHorizontalScrollRange(); int i7 = jfh.j; boolean z = computeHorizontalScrollRange - i7 > 0 && i7 >= jfh.g; jfh.e = z; boolean z2 = jfh.d; if (!z2 && !z) { if (jfh.k != 0) { jfh.b(0); return; } return; } if (z2) { float f = i6; jfh.n = (int) ((f * (computeVerticalScrollOffset + (f / 2.0f))) / computeVerticalScrollRange); jfh.l = Math.min(i6, (i6 * i6) / computeVerticalScrollRange); } if (jfh.e) { float f2 = computeHorizontalScrollOffset; float f3 = i7; jfh.b = (int) ((f3 * (f2 + (f3 / 2.0f))) / computeHorizontalScrollRange); jfh.a = Math.min(i7, (i7 * i7) / computeHorizontalScrollRange); } int i8 = jfh.k; if (i8 == 0 || i8 == 1) { jfh.b(1); } } }; this.A = dao; this.f8228o = stateListDrawable; this.m = drawable; this.w = stateListDrawable2; this.y = drawable2; this.D = Math.max(i, stateListDrawable.getIntrinsicWidth()); this.E = Math.max(i, drawable.getIntrinsicWidth()); this.x = Math.max(i, stateListDrawable2.getIntrinsicWidth()); this.v = Math.max(i, drawable2.getIntrinsicWidth()); this.g = i2; this.C = i3; stateListDrawable.setAlpha(255); drawable.setAlpha(255); ofFloat.addListener(new IeS(this)); ofFloat.addUpdateListener(new Sts(this)); RecyclerView recyclerView2 = this.h; if (recyclerView2 != recyclerView) { if (recyclerView2 != null) { recyclerView2.e(this); RecyclerView recyclerView3 = this.h; recyclerView3.E.remove(this); if (recyclerView3.p == this) { recyclerView3.p = null; } List list = this.h.S; if (list != null) { list.remove(dao); } this.h.removeCallbacks(runnable); } this.h = recyclerView; recyclerView.d(this, -1); this.h.E.add(this); RecyclerView recyclerView4 = this.h; if (recyclerView4.S == null) { recyclerView4.S = new ArrayList(); } recyclerView4.S.add(dao); } } final void b(int i) { if (i == 2 && this.k != 2) { this.f8228o.setState(s); this.h.removeCallbacks(this.t); } if (i != 0) { e(); } else { this.h.invalidate(); } if (this.k == 2 && i != 2) { this.f8228o.setState(r); a(1200); } else if (i == 1) { a(ConnectionResult.DRIVE_EXTERNAL_STORAGE_REQUIRED); } this.k = i; } private void e() { int i = this.c; if (i != 0) { if (i != 3) { return; } else { this.i.cancel(); } } this.c = 1; ValueAnimator valueAnimator = this.i; valueAnimator.setFloatValues(((Float) valueAnimator.getAnimatedValue()).floatValue(), 1.0f); this.i.setDuration(500L); this.i.setStartDelay(0L); this.i.start(); } private void a(int i) { this.h.removeCallbacks(this.t); this.h.postDelayed(this.t, i); } @Override // androidx.recyclerview.widget.RecyclerView.ZqN public final void NS_(Canvas canvas, RecyclerView recyclerView, RecyclerView.AcL acL) { if (this.j != this.h.getWidth() || this.f != this.h.getHeight()) { this.j = this.h.getWidth(); this.f = this.h.getHeight(); b(0); return; } if (this.c != 0) { if (this.d) { int i = this.j; int i2 = this.D; int i3 = i - i2; int i4 = this.n; int i5 = this.l; int i6 = i4 - (i5 / 2); this.f8228o.setBounds(0, 0, i2, i5); this.m.setBounds(0, 0, this.E, this.f); if (ViewCompat.m(this.h) == 1) { this.m.draw(canvas); canvas.translate(this.D, i6); canvas.scale(-1.0f, 1.0f); this.f8228o.draw(canvas); canvas.scale(-1.0f, 1.0f); canvas.translate(-this.D, -i6); } else { canvas.translate(i3, BitmapDescriptorFactory.HUE_RED); this.m.draw(canvas); canvas.translate(BitmapDescriptorFactory.HUE_RED, i6); this.f8228o.draw(canvas); canvas.translate(-i3, -i6); } } if (this.e) { int i7 = this.f; int i8 = this.x; int i9 = this.b; int i10 = this.a; this.w.setBounds(0, 0, i10, i8); this.y.setBounds(0, 0, this.j, this.v); canvas.translate(BitmapDescriptorFactory.HUE_RED, i7 - i8); this.y.draw(canvas); canvas.translate(i9 - (i10 / 2), BitmapDescriptorFactory.HUE_RED); this.w.draw(canvas); canvas.translate(-r2, -r7); } } } @Override // androidx.recyclerview.widget.RecyclerView.jNh public final boolean Ob_(RecyclerView recyclerView, MotionEvent motionEvent) { int i = this.k; if (i == 1) { boolean c = c(motionEvent.getX(), motionEvent.getY()); boolean a = a(motionEvent.getX(), motionEvent.getY()); if (motionEvent.getAction() != 0) { return false; } if (!c && !a) { return false; } if (a) { this.q = 1; this.p = (int) motionEvent.getX(); } else if (c) { this.q = 2; this.B = (int) motionEvent.getY(); } b(2); } else if (i != 2) { return false; } return true; } @Override // androidx.recyclerview.widget.RecyclerView.jNh public final void Oc_(RecyclerView recyclerView, MotionEvent motionEvent) { if (this.k == 0) { return; } if (motionEvent.getAction() == 0) { boolean c = c(motionEvent.getX(), motionEvent.getY()); boolean a = a(motionEvent.getX(), motionEvent.getY()); if (c || a) { if (a) { this.q = 1; this.p = (int) motionEvent.getX(); } else if (c) { this.q = 2; this.B = (int) motionEvent.getY(); } b(2); return; } return; } if (motionEvent.getAction() == 1 && this.k == 2) { this.B = BitmapDescriptorFactory.HUE_RED; this.p = BitmapDescriptorFactory.HUE_RED; b(1); this.q = 0; return; } if (motionEvent.getAction() == 2 && this.k == 2) { e(); if (this.q == 1) { float x = motionEvent.getX(); int[] iArr = this.u; int i = this.C; iArr[0] = i; int i2 = this.j - i; iArr[1] = i2; float max = Math.max(i, Math.min(i2, x)); if (Math.abs(this.b - max) >= 2.0f) { int a2 = a(this.p, max, iArr, this.h.computeHorizontalScrollRange(), this.h.computeHorizontalScrollOffset(), this.j); if (a2 != 0) { this.h.scrollBy(a2, 0); } this.p = max; } } if (this.q == 2) { float y = motionEvent.getY(); int[] iArr2 = this.z; int i3 = this.C; iArr2[0] = i3; int i4 = this.f - i3; iArr2[1] = i4; float max2 = Math.max(i3, Math.min(i4, y)); if (Math.abs(this.n - max2) >= 2.0f) { int a3 = a(this.B, max2, iArr2, this.h.computeVerticalScrollRange(), this.h.computeVerticalScrollOffset(), this.f); if (a3 != 0) { this.h.scrollBy(0, a3); } this.B = max2; } } } } private static int a(float f, float f2, int[] iArr, int i, int i2, int i3) { int i4 = iArr[1] - iArr[0]; if (i4 == 0) { return 0; } int i5 = i - i3; int i6 = (int) (((f2 - f) / i4) * i5); int i7 = i2 + i6; if (i7 >= i5 || i7 < 0) { return 0; } return i6; } private boolean c(float f, float f2) { if (ViewCompat.m(this.h) == 1 ? f <= this.D : f >= this.j - this.D) { int i = this.n; int i2 = this.l / 2; if (f2 >= i - i2 && f2 <= i + i2) { return true; } } return false; } private boolean a(float f, float f2) { if (f2 >= this.f - this.x) { int i = this.b; int i2 = this.a / 2; if (f >= i - i2 && f <= i + i2) { return true; } } return false; } /* loaded from: classes.dex */ class IeS extends AnimatorListenerAdapter { final Jfh b; private boolean e = false; IeS(Jfh jfh) { this.b = jfh; } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public final void onAnimationEnd(Animator animator) { if (this.e) { this.e = false; } else if (((Float) this.b.i.getAnimatedValue()).floatValue() == BitmapDescriptorFactory.HUE_RED) { this.b.c = 0; this.b.b(0); } else { this.b.c = 2; this.b.h.invalidate(); } } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public final void onAnimationCancel(Animator animator) { this.e = true; } } /* loaded from: classes.dex */ class Sts implements ValueAnimator.AnimatorUpdateListener { final Jfh d; Sts(Jfh jfh) { this.d = jfh; } @Override // android.animation.ValueAnimator.AnimatorUpdateListener public final void onAnimationUpdate(ValueAnimator valueAnimator) { int floatValue = (int) (((Float) valueAnimator.getAnimatedValue()).floatValue() * 255.0f); this.d.f8228o.setAlpha(floatValue); this.d.m.setAlpha(floatValue); this.d.h.invalidate(); } } }