package o; import android.graphics.Rect; import android.view.View; import android.view.ViewGroup; import androidx.core.view.ViewCompat; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.StaggeredGridLayoutManager; /* loaded from: classes2.dex */ public final class BvX { public static int e(int i) { switch (i) { case -1: return -1; case 0: case 2: case 4: return 0; case 1: case 3: case 5: return 1; default: StringBuilder sb = new StringBuilder("Unknown layout type (= "); sb.append(i); sb.append(")"); throw new IllegalArgumentException(sb.toString()); } } public static int b(RecyclerView.tOB tob) { if (tob instanceof GridLayoutManager) { return ((GridLayoutManager) tob).h == 0 ? 2 : 3; } if (tob instanceof LinearLayoutManager) { return ((LinearLayoutManager) tob).h == 0 ? 0 : 1; } if (tob instanceof StaggeredGridLayoutManager) { return ((StaggeredGridLayoutManager) tob).c == 0 ? 4 : 5; } return -1; } public static View Od_(ViewGroup viewGroup, float f, float f2) { for (int childCount = viewGroup.getChildCount() - 1; childCount >= 0; childCount--) { View childAt = viewGroup.getChildAt(childCount); if (f >= childAt.getLeft() && f <= childAt.getRight() && f2 >= childAt.getTop() && f2 <= childAt.getBottom()) { return childAt; } } return null; } public static Rect Of_(View view, Rect rect) { ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); if (layoutParams instanceof ViewGroup.MarginLayoutParams) { ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams; rect.left = marginLayoutParams.leftMargin; rect.right = marginLayoutParams.rightMargin; rect.top = marginLayoutParams.topMargin; rect.bottom = marginLayoutParams.bottomMargin; } else { rect.bottom = 0; rect.top = 0; rect.right = 0; rect.left = 0; } return rect; } public static Rect Oe_(View view, Rect rect) { rect.left = RecyclerView.tOB.h(view); rect.right = RecyclerView.tOB.j(view); rect.top = RecyclerView.tOB.m(view); rect.bottom = RecyclerView.tOB.b(view); return rect; } public static int d(RecyclerView.tOB tob) { if (!(tob instanceof GridLayoutManager)) { if (!(tob instanceof LinearLayoutManager)) { if (tob instanceof StaggeredGridLayoutManager) { return ((StaggeredGridLayoutManager) tob).c; } return -1; } return ((LinearLayoutManager) tob).h; } return ((GridLayoutManager) tob).h; } public static int e(RecyclerView recyclerView, boolean z) { RecyclerView.tOB tob = recyclerView.x; if (!(tob instanceof LinearLayoutManager)) { return -1; } if (z) { LinearLayoutManager linearLayoutManager = (LinearLayoutManager) tob; View d = d(linearLayoutManager, 0, linearLayoutManager.i_()); if (d == null) { return -1; } return LinearLayoutManager.f(d); } return ((LinearLayoutManager) tob).j(); } public static View d(LinearLayoutManager linearLayoutManager, int i, int i2) { int i3; boolean z = linearLayoutManager.h == 1; if (z) { i3 = linearLayoutManager.l; } else { i3 = linearLayoutManager.w; } int i4 = i2 <= i ? -1 : 1; while (i != i2) { View f = linearLayoutManager.f(i); int top = z ? f.getTop() : f.getLeft(); int bottom = z ? f.getBottom() : f.getRight(); if (top < i3 && bottom > 0) { return f; } i += i4; } return null; } public static int d(RecyclerView recyclerView) { RecyclerView.tOB tob = recyclerView.x; if (!(tob instanceof GridLayoutManager)) { if (tob instanceof StaggeredGridLayoutManager) { return ((StaggeredGridLayoutManager) tob).a; } return 1; } return ((GridLayoutManager) tob).e; } public static int e(RecyclerView.zJl zjl) { View view = null; if (zjl != null) { View view2 = zjl.itemView; if (ViewCompat.G(view2)) { view = view2; } } if (view == null) { return -1; } ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); if (!(layoutParams instanceof StaggeredGridLayoutManager.LWm)) { if (layoutParams instanceof GridLayoutManager.HBt) { return ((GridLayoutManager.HBt) layoutParams).a; } return layoutParams instanceof RecyclerView.saX ? 1 : -1; } boolean z = ((StaggeredGridLayoutManager.LWm) layoutParams).a; return 1; } }