package o; import android.graphics.PointF; import android.util.DisplayMetrics; import android.view.View; import android.view.animation.DecelerateInterpolator; import androidx.recyclerview.widget.RecyclerView; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import o.MSs; import org.bouncycastle.asn1.cmp.PKIFailureInfo; /* loaded from: classes.dex */ public class SxS extends gxT { private MSs b; private MSs e; @Override // o.gxT public final int[] c(RecyclerView.tOB tob, View view) { int[] iArr = new int[2]; if (tob.d()) { MSs d = d(tob); iArr[0] = (d.c(view) + (d.e(view) / 2)) - (d.i() + (d.h() / 2)); } else { iArr[0] = 0; } if (tob.c()) { MSs c = c(tob); iArr[1] = (c.c(view) + (c.e(view) / 2)) - (c.i() + (c.h() / 2)); } else { iArr[1] = 0; } return iArr; } @Override // o.gxT public View b(RecyclerView.tOB tob) { if (tob.c()) { return a(tob, c(tob)); } if (tob.d()) { return a(tob, d(tob)); } return null; } /* JADX WARN: Multi-variable type inference failed */ @Override // o.gxT public final int b(RecyclerView.tOB tob, int i, int i2) { MSs d; PointF Hy_; int r = tob.r(); if (r == 0) { return -1; } if (tob.c()) { d = c(tob); } else { d = tob.d() ? d(tob) : null; } if (d == null) { return -1; } Emo emo = tob.k; boolean z = false; int c = emo != null ? emo.d.c() - emo.b.size() : 0; int i3 = Integer.MAX_VALUE; int i4 = PKIFailureInfo.systemUnavail; View view = null; View view2 = null; for (int i5 = 0; i5 < c; i5++) { Emo emo2 = tob.k; View e = emo2 != null ? emo2.d.e(emo2.a(i5)) : null; if (e != null) { int c2 = (d.c(e) + (d.e(e) / 2)) - (d.i() + (d.h() / 2)); if (c2 <= 0 && c2 > i4) { view = e; i4 = c2; } if (c2 >= 0 && c2 < i3) { view2 = e; i3 = c2; } } } boolean z2 = !tob.d() ? i2 <= 0 : i <= 0; if (z2 && view2 != null) { return RecyclerView.tOB.f(view2); } if (!z2 && view != null) { return RecyclerView.tOB.f(view); } if (!z2) { view = view2; } if (view == null) { return -1; } int f = RecyclerView.tOB.f(view); int r2 = tob.r(); if ((tob instanceof RecyclerView.CeN.RVV) && (Hy_ = ((RecyclerView.CeN.RVV) tob).Hy_(r2 - 1)) != null && (Hy_.x < BitmapDescriptorFactory.HUE_RED || Hy_.y < BitmapDescriptorFactory.HUE_RED)) { z = true; } int i6 = f + (z == z2 ? -1 : 1); if (i6 < 0 || i6 >= r) { return -1; } return i6; } @Override // o.gxT protected final RecyclerView.CeN a(RecyclerView.tOB tob) { if (tob instanceof RecyclerView.CeN.RVV) { return new C11786els(this, this.c.getContext()) { // from class: o.SxS.1 final SxS a; { this.a = this; } @Override // o.C11786els, androidx.recyclerview.widget.RecyclerView.CeN public final void b(View view, RecyclerView.AcL acL, RecyclerView.CeN.IeS ieS) { SxS sxS = this.a; int[] c = sxS.c(sxS.c.x, view); int i = c[0]; int i2 = c[1]; int ceil = (int) Math.ceil(c(Math.max(Math.abs(i), Math.abs(i2))) / 0.3356d); if (ceil > 0) { DecelerateInterpolator decelerateInterpolator = this.b; ieS.e = i; ieS.d = i2; ieS.a = ceil; ieS.c = decelerateInterpolator; ieS.b = true; } } @Override // o.C11786els protected final float aoq_(DisplayMetrics displayMetrics) { return 100.0f / displayMetrics.densityDpi; } /* JADX INFO: Access modifiers changed from: protected */ @Override // o.C11786els public final int c(int i) { return Math.min(100, super.c(i)); } }; } return null; } private static View a(RecyclerView.tOB tob, MSs mSs) { Emo emo = tob.k; int c = emo != null ? emo.d.c() - emo.b.size() : 0; if (c == 0) { return null; } int i = mSs.i(); int h = mSs.h() / 2; int i2 = Integer.MAX_VALUE; View view = null; for (int i3 = 0; i3 < c; i3++) { Emo emo2 = tob.k; View e = emo2 != null ? emo2.d.e(emo2.a(i3)) : null; int abs = Math.abs((mSs.c(e) + (mSs.e(e) / 2)) - (i + h)); if (abs < i2) { view = e; i2 = abs; } } return view; } private MSs c(RecyclerView.tOB tob) { MSs mSs = this.b; if (mSs == null || mSs.b != tob) { this.b = new MSs.AnonymousClass3(tob); } return this.b; } private MSs d(RecyclerView.tOB tob) { MSs mSs = this.e; if (mSs == null || mSs.b != tob) { this.e = new MSs.AnonymousClass4(tob); } return this.e; } }