package o; import android.graphics.Rect; import android.view.View; import android.view.ViewGroup; import androidx.recyclerview.widget.RecyclerView; /* loaded from: classes5.dex */ public final class eCA extends RecyclerView.ZqN { private int c; public eCA() { this.c = 0; } public eCA(int i) { this.c = i; } @Override // androidx.recyclerview.widget.RecyclerView.ZqN public final void apG_(Rect rect, View view, RecyclerView recyclerView, RecyclerView.AcL acL) { int d = RecyclerView.d(view); int itemCount = recyclerView.g.getItemCount(); if (itemCount == -1 || itemCount - 1 != d) { if ((recyclerView.g instanceof AbstractC12009eqC) && ((AbstractC12009eqC) recyclerView.g).a != null) { r3 = 1; } if ((r3 == 0 || d <= 1) && (r3 != 0 || d <= 0)) { return; } rect.top = this.c; return; } if (!(recyclerView.g instanceof AbstractC12398exU) || ((AbstractC12398exU) recyclerView.g).e()) { int height = (recyclerView.getHeight() - recyclerView.getPaddingTop()) - recyclerView.getPaddingBottom(); int min = Math.min(recyclerView.getChildCount(), itemCount); int i = 0; for (int i2 = 0; i2 < min - 1; i2++) { RecyclerView.saX sax = (RecyclerView.saX) recyclerView.getChildAt(i2).getLayoutParams(); i += recyclerView.getChildAt(i2).getHeight() + ((ViewGroup.MarginLayoutParams) sax).topMargin + ((ViewGroup.MarginLayoutParams) sax).bottomMargin; } int height2 = view.getHeight(); if (height2 == 0) { if (view.getLayoutParams() == null) { view.setLayoutParams(new ViewGroup.LayoutParams(-2, -2)); } view.measure(ViewGroup.getChildMeasureSpec(View.MeasureSpec.makeMeasureSpec(recyclerView.getWidth(), 1073741824), recyclerView.getPaddingLeft() + recyclerView.getPaddingRight(), view.getLayoutParams().width), ViewGroup.getChildMeasureSpec(View.MeasureSpec.makeMeasureSpec(recyclerView.getHeight(), 0), recyclerView.getPaddingTop() + recyclerView.getPaddingBottom(), view.getLayoutParams().height)); view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight()); height2 = view.getHeight(); } int paddingBottom = height - (i + ((height2 + view.getPaddingBottom()) + view.getPaddingTop())); rect.top = paddingBottom >= 0 ? paddingBottom : 0; } } }