package androidx.recyclerview.widget; import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.util.Log; import android.util.SparseIntArray; import android.view.View; import android.view.ViewGroup; import android.widget.GridView; import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; /* loaded from: classes2.dex */ public class GridLayoutManager extends LinearLayoutManager { private static final boolean DEBUG = false; public static final int DEFAULT_SPAN_COUNT = -1; private static final String TAG = "GridLayoutManager"; int[] mCachedBorders; final Rect mDecorInsets; boolean mPendingSpanCountChange; final SparseIntArray mPreLayoutSpanIndexCache; final SparseIntArray mPreLayoutSpanSizeCache; View[] mSet; int mSpanCount; SpanSizeLookup mSpanSizeLookup; private boolean mUsingSpansToEstimateScrollBarDimensions; public int getSpanCount() { return this.mSpanCount; } public SpanSizeLookup getSpanSizeLookup() { return this.mSpanSizeLookup; } public boolean isUsingSpansToEstimateScrollbarDimensions() { return this.mUsingSpansToEstimateScrollBarDimensions; } public void setSpanSizeLookup(SpanSizeLookup spanSizeLookup) { this.mSpanSizeLookup = spanSizeLookup; } public void setUsingSpansToEstimateScrollbarDimensions(boolean z) { this.mUsingSpansToEstimateScrollBarDimensions = z; } public GridLayoutManager(Context context, AttributeSet attributeSet, int i, int i2) { super(context, attributeSet, i, i2); this.mPendingSpanCountChange = false; this.mSpanCount = -1; this.mPreLayoutSpanSizeCache = new SparseIntArray(); this.mPreLayoutSpanIndexCache = new SparseIntArray(); this.mSpanSizeLookup = new DefaultSpanSizeLookup(); this.mDecorInsets = new Rect(); setSpanCount(getProperties(context, attributeSet, i, i2).spanCount); } public GridLayoutManager(Context context, int i) { super(context); this.mPendingSpanCountChange = false; this.mSpanCount = -1; this.mPreLayoutSpanSizeCache = new SparseIntArray(); this.mPreLayoutSpanIndexCache = new SparseIntArray(); this.mSpanSizeLookup = new DefaultSpanSizeLookup(); this.mDecorInsets = new Rect(); setSpanCount(i); } public GridLayoutManager(Context context, int i, int i2, boolean z) { super(context, i2, z); this.mPendingSpanCountChange = false; this.mSpanCount = -1; this.mPreLayoutSpanSizeCache = new SparseIntArray(); this.mPreLayoutSpanIndexCache = new SparseIntArray(); this.mSpanSizeLookup = new DefaultSpanSizeLookup(); this.mDecorInsets = new Rect(); setSpanCount(i); } @Override // androidx.recyclerview.widget.LinearLayoutManager public void setStackFromEnd(boolean z) { if (z) { throw new UnsupportedOperationException("GridLayoutManager does not support stack from end. Consider using reverse layout"); } super.setStackFromEnd(false); } @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager public int getRowCountForAccessibility(RecyclerView.Recycler recycler, RecyclerView.State state) { if (this.mOrientation == 0) { return this.mSpanCount; } if (state.getItemCount() < 1) { return 0; } return getSpanGroupIndex(recycler, state, state.getItemCount() - 1) + 1; } @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager public int getColumnCountForAccessibility(RecyclerView.Recycler recycler, RecyclerView.State state) { if (this.mOrientation == 1) { return this.mSpanCount; } if (state.getItemCount() < 1) { return 0; } return getSpanGroupIndex(recycler, state, state.getItemCount() - 1) + 1; } @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager public void onInitializeAccessibilityNodeInfoForItem(RecyclerView.Recycler recycler, RecyclerView.State state, View view, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) { ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); if (!(layoutParams instanceof LayoutParams)) { super.onInitializeAccessibilityNodeInfoForItem(view, accessibilityNodeInfoCompat); return; } LayoutParams layoutParams2 = (LayoutParams) layoutParams; int spanGroupIndex = getSpanGroupIndex(recycler, state, layoutParams2.getViewLayoutPosition()); if (this.mOrientation == 0) { accessibilityNodeInfoCompat.setCollectionItemInfo(AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(layoutParams2.getSpanIndex(), layoutParams2.getSpanSize(), spanGroupIndex, 1, false, false)); } else { accessibilityNodeInfoCompat.setCollectionItemInfo(AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(spanGroupIndex, 1, layoutParams2.getSpanIndex(), layoutParams2.getSpanSize(), false, false)); } } @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager public void onInitializeAccessibilityNodeInfo(RecyclerView.Recycler recycler, RecyclerView.State state, AccessibilityNodeInfoCompat accessibilityNodeInfoCompat) { super.onInitializeAccessibilityNodeInfo(recycler, state, accessibilityNodeInfoCompat); accessibilityNodeInfoCompat.setClassName(GridView.class.getName()); } @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) { if (state.isPreLayout()) { cachePreLayoutSpanMapping(); } super.onLayoutChildren(recycler, state); clearPreLayoutSpanMappingCache(); } @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager public void onLayoutCompleted(RecyclerView.State state) { super.onLayoutCompleted(state); this.mPendingSpanCountChange = false; } private void clearPreLayoutSpanMappingCache() { this.mPreLayoutSpanSizeCache.clear(); this.mPreLayoutSpanIndexCache.clear(); } private void cachePreLayoutSpanMapping() { int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { LayoutParams layoutParams = (LayoutParams) getChildAt(i).getLayoutParams(); int viewLayoutPosition = layoutParams.getViewLayoutPosition(); this.mPreLayoutSpanSizeCache.put(viewLayoutPosition, layoutParams.getSpanSize()); this.mPreLayoutSpanIndexCache.put(viewLayoutPosition, layoutParams.getSpanIndex()); } } @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager public void onItemsAdded(RecyclerView recyclerView, int i, int i2) { this.mSpanSizeLookup.invalidateSpanIndexCache(); this.mSpanSizeLookup.invalidateSpanGroupIndexCache(); } @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager public void onItemsChanged(RecyclerView recyclerView) { this.mSpanSizeLookup.invalidateSpanIndexCache(); this.mSpanSizeLookup.invalidateSpanGroupIndexCache(); } @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager public void onItemsRemoved(RecyclerView recyclerView, int i, int i2) { this.mSpanSizeLookup.invalidateSpanIndexCache(); this.mSpanSizeLookup.invalidateSpanGroupIndexCache(); } @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager public void onItemsUpdated(RecyclerView recyclerView, int i, int i2, Object obj) { this.mSpanSizeLookup.invalidateSpanIndexCache(); this.mSpanSizeLookup.invalidateSpanGroupIndexCache(); } @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager public void onItemsMoved(RecyclerView recyclerView, int i, int i2, int i3) { this.mSpanSizeLookup.invalidateSpanIndexCache(); this.mSpanSizeLookup.invalidateSpanGroupIndexCache(); } @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager public RecyclerView.LayoutParams generateDefaultLayoutParams() { if (this.mOrientation == 0) { return new LayoutParams(-2, -1); } return new LayoutParams(-1, -2); } @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager public RecyclerView.LayoutParams generateLayoutParams(Context context, AttributeSet attributeSet) { return new LayoutParams(context, attributeSet); } @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager public RecyclerView.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) { if (layoutParams instanceof ViewGroup.MarginLayoutParams) { return new LayoutParams((ViewGroup.MarginLayoutParams) layoutParams); } return new LayoutParams(layoutParams); } @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager public boolean checkLayoutParams(RecyclerView.LayoutParams layoutParams) { return layoutParams instanceof LayoutParams; } private void updateMeasurements() { int height; int paddingTop; if (getOrientation() == 1) { height = getWidth() - getPaddingRight(); paddingTop = getPaddingLeft(); } else { height = getHeight() - getPaddingBottom(); paddingTop = getPaddingTop(); } calculateItemBorders(height - paddingTop); } @Override // androidx.recyclerview.widget.RecyclerView.LayoutManager public void setMeasuredDimension(Rect rect, int i, int i2) { int chooseSize; int chooseSize2; if (this.mCachedBorders == null) { super.setMeasuredDimension(rect, i, i2); } int paddingLeft = getPaddingLeft() + getPaddingRight(); int paddingTop = getPaddingTop() + getPaddingBottom(); if (this.mOrientation == 1) { chooseSize2 = chooseSize(i2, rect.height() + paddingTop, getMinimumHeight()); int[] iArr = this.mCachedBorders; chooseSize = chooseSize(i, iArr[iArr.length - 1] + paddingLeft, getMinimumWidth()); } else { chooseSize = chooseSize(i, rect.width() + paddingLeft, getMinimumWidth()); int[] iArr2 = this.mCachedBorders; chooseSize2 = chooseSize(i2, iArr2[iArr2.length - 1] + paddingTop, getMinimumHeight()); } setMeasuredDimension(chooseSize, chooseSize2); } private void calculateItemBorders(int i) { this.mCachedBorders = calculateItemBorders(this.mCachedBorders, this.mSpanCount, i); } static int[] calculateItemBorders(int[] iArr, int i, int i2) { int i3; if (iArr == null || iArr.length != i + 1 || iArr[iArr.length - 1] != i2) { iArr = new int[i + 1]; } int i4 = 0; iArr[0] = 0; int i5 = i2 / i; int i6 = i2 % i; int i7 = 0; for (int i8 = 1; i8 <= i; i8++) { i4 += i6; if (i4 <= 0 || i - i4 >= i6) { i3 = i5; } else { i3 = i5 + 1; i4 -= i; } i7 += i3; iArr[i8] = i7; } return iArr; } int getSpaceForSpanRange(int i, int i2) { if (this.mOrientation == 1 && isLayoutRTL()) { int[] iArr = this.mCachedBorders; int i3 = this.mSpanCount; return iArr[i3 - i] - iArr[(i3 - i) - i2]; } int[] iArr2 = this.mCachedBorders; return iArr2[i2 + i] - iArr2[i]; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // androidx.recyclerview.widget.LinearLayoutManager public void onAnchorReady(RecyclerView.Recycler recycler, RecyclerView.State state, LinearLayoutManager.AnchorInfo anchorInfo, int i) { super.onAnchorReady(recycler, state, anchorInfo, i); updateMeasurements(); if (state.getItemCount() > 0 && !state.isPreLayout()) { ensureAnchorIsInCorrectSpan(recycler, state, anchorInfo, i); } ensureViewSet(); } private void ensureViewSet() { View[] viewArr = this.mSet; if (viewArr == null || viewArr.length != this.mSpanCount) { this.mSet = new View[this.mSpanCount]; } } @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager public int scrollHorizontallyBy(int i, RecyclerView.Recycler recycler, RecyclerView.State state) { updateMeasurements(); ensureViewSet(); return super.scrollHorizontallyBy(i, recycler, state); } @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager public int scrollVerticallyBy(int i, RecyclerView.Recycler recycler, RecyclerView.State state) { updateMeasurements(); ensureViewSet(); return super.scrollVerticallyBy(i, recycler, state); } private void ensureAnchorIsInCorrectSpan(RecyclerView.Recycler recycler, RecyclerView.State state, LinearLayoutManager.AnchorInfo anchorInfo, int i) { boolean z = i == 1; int spanIndex = getSpanIndex(recycler, state, anchorInfo.mPosition); if (z) { while (spanIndex > 0 && anchorInfo.mPosition > 0) { anchorInfo.mPosition--; spanIndex = getSpanIndex(recycler, state, anchorInfo.mPosition); } return; } int itemCount = state.getItemCount() - 1; int i2 = anchorInfo.mPosition; while (i2 < itemCount) { int i3 = i2 + 1; int spanIndex2 = getSpanIndex(recycler, state, i3); if (spanIndex2 <= spanIndex) { break; } i2 = i3; spanIndex = spanIndex2; } anchorInfo.mPosition = i2; } @Override // androidx.recyclerview.widget.LinearLayoutManager View findReferenceChild(RecyclerView.Recycler recycler, RecyclerView.State state, boolean z, boolean z2) { int i; int i2; int childCount = getChildCount(); int i3 = 1; if (z2) { i2 = getChildCount() - 1; i = -1; i3 = -1; } else { i = childCount; i2 = 0; } int itemCount = state.getItemCount(); ensureLayoutState(); int startAfterPadding = this.mOrientationHelper.getStartAfterPadding(); int endAfterPadding = this.mOrientationHelper.getEndAfterPadding(); View view = null; View view2 = null; while (i2 != i) { View childAt = getChildAt(i2); int position = getPosition(childAt); if (position >= 0 && position < itemCount && getSpanIndex(recycler, state, position) == 0) { if (((RecyclerView.LayoutParams) childAt.getLayoutParams()).isItemRemoved()) { if (view2 == null) { view2 = childAt; } } else { if (this.mOrientationHelper.getDecoratedStart(childAt) < endAfterPadding && this.mOrientationHelper.getDecoratedEnd(childAt) >= startAfterPadding) { return childAt; } if (view == null) { view = childAt; } } } i2 += i3; } return view != null ? view : view2; } private int getSpanGroupIndex(RecyclerView.Recycler recycler, RecyclerView.State state, int i) { if (!state.isPreLayout()) { return this.mSpanSizeLookup.getCachedSpanGroupIndex(i, this.mSpanCount); } int convertPreLayoutPositionToPostLayout = recycler.convertPreLayoutPositionToPostLayout(i); if (convertPreLayoutPositionToPostLayout == -1) { Log.w(TAG, "Cannot find span size for pre layout position. " + i); return 0; } return this.mSpanSizeLookup.getCachedSpanGroupIndex(convertPreLayoutPositionToPostLayout, this.mSpanCount); } private int getSpanIndex(RecyclerView.Recycler recycler, RecyclerView.State state, int i) { if (!state.isPreLayout()) { return this.mSpanSizeLookup.getCachedSpanIndex(i, this.mSpanCount); } int i2 = this.mPreLayoutSpanIndexCache.get(i, -1); if (i2 != -1) { return i2; } int convertPreLayoutPositionToPostLayout = recycler.convertPreLayoutPositionToPostLayout(i); if (convertPreLayoutPositionToPostLayout == -1) { Log.w(TAG, "Cannot find span size for pre layout position. It is not cached, not in the adapter. Pos:" + i); return 0; } return this.mSpanSizeLookup.getCachedSpanIndex(convertPreLayoutPositionToPostLayout, this.mSpanCount); } private int getSpanSize(RecyclerView.Recycler recycler, RecyclerView.State state, int i) { if (!state.isPreLayout()) { return this.mSpanSizeLookup.getSpanSize(i); } int i2 = this.mPreLayoutSpanSizeCache.get(i, -1); if (i2 != -1) { return i2; } int convertPreLayoutPositionToPostLayout = recycler.convertPreLayoutPositionToPostLayout(i); if (convertPreLayoutPositionToPostLayout == -1) { Log.w(TAG, "Cannot find span size for pre layout position. It is not cached, not in the adapter. Pos:" + i); return 1; } return this.mSpanSizeLookup.getSpanSize(convertPreLayoutPositionToPostLayout); } @Override // androidx.recyclerview.widget.LinearLayoutManager void collectPrefetchPositionsForLayoutState(RecyclerView.State state, LinearLayoutManager.LayoutState layoutState, RecyclerView.LayoutManager.LayoutPrefetchRegistry layoutPrefetchRegistry) { int i = this.mSpanCount; for (int i2 = 0; i2 < this.mSpanCount && layoutState.hasMore(state) && i > 0; i2++) { int i3 = layoutState.mCurrentPosition; layoutPrefetchRegistry.addPosition(i3, Math.max(0, layoutState.mScrollingOffset)); i -= this.mSpanSizeLookup.getSpanSize(i3); layoutState.mCurrentPosition += layoutState.mItemDirection; } } /* JADX WARN: Code restructure failed: missing block: B:30:0x00a2, code lost: r21.mFinished = true; */ /* JADX WARN: Code restructure failed: missing block: B:31:0x00a4, code lost: return; */ @Override // androidx.recyclerview.widget.LinearLayoutManager /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ void layoutChunk(androidx.recyclerview.widget.RecyclerView.Recycler r18, androidx.recyclerview.widget.RecyclerView.State r19, androidx.recyclerview.widget.LinearLayoutManager.LayoutState r20, androidx.recyclerview.widget.LinearLayoutManager.LayoutChunkResult r21) { /* Method dump skipped, instructions count: 559 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.GridLayoutManager.layoutChunk(androidx.recyclerview.widget.RecyclerView$Recycler, androidx.recyclerview.widget.RecyclerView$State, androidx.recyclerview.widget.LinearLayoutManager$LayoutState, androidx.recyclerview.widget.LinearLayoutManager$LayoutChunkResult):void"); } private void measureChild(View view, int i, boolean z) { int i2; int i3; LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); Rect rect = layoutParams.mDecorInsets; int i4 = rect.top + rect.bottom + layoutParams.topMargin + layoutParams.bottomMargin; int i5 = rect.left + rect.right + layoutParams.leftMargin + layoutParams.rightMargin; int spaceForSpanRange = getSpaceForSpanRange(layoutParams.mSpanIndex, layoutParams.mSpanSize); if (this.mOrientation == 1) { i3 = getChildMeasureSpec(spaceForSpanRange, i, i5, layoutParams.width, false); i2 = getChildMeasureSpec(this.mOrientationHelper.getTotalSpace(), getHeightMode(), i4, layoutParams.height, true); } else { int childMeasureSpec = getChildMeasureSpec(spaceForSpanRange, i, i4, layoutParams.height, false); int childMeasureSpec2 = getChildMeasureSpec(this.mOrientationHelper.getTotalSpace(), getWidthMode(), i5, layoutParams.width, true); i2 = childMeasureSpec; i3 = childMeasureSpec2; } measureChildWithDecorationsAndMargin(view, i3, i2, z); } private void guessMeasurement(float f, int i) { calculateItemBorders(Math.max(Math.round(f * this.mSpanCount), i)); } private void measureChildWithDecorationsAndMargin(View view, int i, int i2, boolean z) { boolean shouldMeasureChild; RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) view.getLayoutParams(); if (z) { shouldMeasureChild = shouldReMeasureChild(view, i, i2, layoutParams); } else { shouldMeasureChild = shouldMeasureChild(view, i, i2, layoutParams); } if (shouldMeasureChild) { view.measure(i, i2); } } private void assignSpans(RecyclerView.Recycler recycler, RecyclerView.State state, int i, boolean z) { int i2; int i3; int i4; int i5 = 0; if (z) { i4 = 1; i3 = i; i2 = 0; } else { i2 = i - 1; i3 = -1; i4 = -1; } while (i2 != i3) { View view = this.mSet[i2]; LayoutParams layoutParams = (LayoutParams) view.getLayoutParams(); layoutParams.mSpanSize = getSpanSize(recycler, state, getPosition(view)); layoutParams.mSpanIndex = i5; i5 += layoutParams.mSpanSize; i2 += i4; } } public void setSpanCount(int i) { if (i == this.mSpanCount) { return; } this.mPendingSpanCountChange = true; if (i < 1) { throw new IllegalArgumentException("Span count should be at least 1. Provided " + i); } this.mSpanCount = i; this.mSpanSizeLookup.invalidateSpanIndexCache(); requestLayout(); } /* loaded from: classes2.dex */ public static abstract class SpanSizeLookup { final SparseIntArray mSpanIndexCache = new SparseIntArray(); final SparseIntArray mSpanGroupIndexCache = new SparseIntArray(); private boolean mCacheSpanIndices = false; private boolean mCacheSpanGroupIndices = false; public abstract int getSpanSize(int i); public boolean isSpanGroupIndexCacheEnabled() { return this.mCacheSpanGroupIndices; } public boolean isSpanIndexCacheEnabled() { return this.mCacheSpanIndices; } public void setSpanIndexCacheEnabled(boolean z) { if (!z) { this.mSpanGroupIndexCache.clear(); } this.mCacheSpanIndices = z; } public void setSpanGroupIndexCacheEnabled(boolean z) { if (!z) { this.mSpanGroupIndexCache.clear(); } this.mCacheSpanGroupIndices = z; } public void invalidateSpanIndexCache() { this.mSpanIndexCache.clear(); } public void invalidateSpanGroupIndexCache() { this.mSpanGroupIndexCache.clear(); } int getCachedSpanIndex(int i, int i2) { if (!this.mCacheSpanIndices) { return getSpanIndex(i, i2); } int i3 = this.mSpanIndexCache.get(i, -1); if (i3 != -1) { return i3; } int spanIndex = getSpanIndex(i, i2); this.mSpanIndexCache.put(i, spanIndex); return spanIndex; } int getCachedSpanGroupIndex(int i, int i2) { if (!this.mCacheSpanGroupIndices) { return getSpanGroupIndex(i, i2); } int i3 = this.mSpanGroupIndexCache.get(i, -1); if (i3 != -1) { return i3; } int spanGroupIndex = getSpanGroupIndex(i, i2); this.mSpanGroupIndexCache.put(i, spanGroupIndex); return spanGroupIndex; } /* JADX WARN: Removed duplicated region for block: B:12:0x0024 */ /* JADX WARN: Removed duplicated region for block: B:17:0x0033 */ /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:14:0x002b -> B:10:0x0030). Please report as a decompilation issue!!! */ /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:15:0x002d -> B:10:0x0030). Please report as a decompilation issue!!! */ /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:16:0x002f -> B:10:0x0030). Please report as a decompilation issue!!! */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public int getSpanIndex(int r6, int r7) { /* r5 = this; int r0 = r5.getSpanSize(r6) r1 = 0 if (r0 != r7) goto L8 return r1 L8: boolean r2 = r5.mCacheSpanIndices if (r2 == 0) goto L20 android.util.SparseIntArray r2 = r5.mSpanIndexCache int r2 = findFirstKeyLessThan(r2, r6) if (r2 < 0) goto L20 android.util.SparseIntArray r3 = r5.mSpanIndexCache int r3 = r3.get(r2) int r4 = r5.getSpanSize(r2) int r3 = r3 + r4 goto L30 L20: r2 = r1 r3 = r2 L22: if (r2 >= r6) goto L33 int r4 = r5.getSpanSize(r2) int r3 = r3 + r4 if (r3 != r7) goto L2d r3 = r1 goto L30 L2d: if (r3 <= r7) goto L30 r3 = r4 L30: int r2 = r2 + 1 goto L22 L33: int r0 = r0 + r3 if (r0 > r7) goto L37 return r3 L37: return r1 */ throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup.getSpanIndex(int, int):int"); } static int findFirstKeyLessThan(SparseIntArray sparseIntArray, int i) { int size = sparseIntArray.size() - 1; int i2 = 0; while (i2 <= size) { int i3 = (i2 + size) >>> 1; if (sparseIntArray.keyAt(i3) < i) { i2 = i3 + 1; } else { size = i3 - 1; } } int i4 = i2 - 1; if (i4 < 0 || i4 >= sparseIntArray.size()) { return -1; } return sparseIntArray.keyAt(i4); } public int getSpanGroupIndex(int i, int i2) { int i3; int i4; int i5; int findFirstKeyLessThan; if (!this.mCacheSpanGroupIndices || (findFirstKeyLessThan = findFirstKeyLessThan(this.mSpanGroupIndexCache, i)) == -1) { i3 = 0; i4 = 0; i5 = 0; } else { i3 = this.mSpanGroupIndexCache.get(findFirstKeyLessThan); i4 = findFirstKeyLessThan + 1; i5 = getCachedSpanIndex(findFirstKeyLessThan, i2) + getSpanSize(findFirstKeyLessThan); if (i5 == i2) { i3++; i5 = 0; } } int spanSize = getSpanSize(i); while (i4 < i) { int spanSize2 = getSpanSize(i4); i5 += spanSize2; if (i5 == i2) { i3++; i5 = 0; } else if (i5 > i2) { i3++; i5 = spanSize2; } i4++; } return i5 + spanSize > i2 ? i3 + 1 : i3; } } /* JADX WARN: Code restructure failed: missing block: B:63:0x00d2, code lost: if (r13 == (r2 > r15)) goto L45; */ /* JADX WARN: Code restructure failed: missing block: B:76:0x00f2, code lost: if (r13 == (r2 > r10)) goto L68; */ /* JADX WARN: Removed duplicated region for block: B:50:0x00fa */ /* JADX WARN: Removed duplicated region for block: B:52:0x010f */ @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public android.view.View onFocusSearchFailed(android.view.View r23, int r24, androidx.recyclerview.widget.RecyclerView.Recycler r25, androidx.recyclerview.widget.RecyclerView.State r26) { /* Method dump skipped, instructions count: 326 To view this dump add '--comments-level debug' option */ throw new UnsupportedOperationException("Method not decompiled: androidx.recyclerview.widget.GridLayoutManager.onFocusSearchFailed(android.view.View, int, androidx.recyclerview.widget.RecyclerView$Recycler, androidx.recyclerview.widget.RecyclerView$State):android.view.View"); } @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager public boolean supportsPredictiveItemAnimations() { return this.mPendingSavedState == null && !this.mPendingSpanCountChange; } @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager public int computeHorizontalScrollRange(RecyclerView.State state) { if (this.mUsingSpansToEstimateScrollBarDimensions) { return computeScrollRangeWithSpanInfo(state); } return super.computeHorizontalScrollRange(state); } @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager public int computeVerticalScrollRange(RecyclerView.State state) { if (this.mUsingSpansToEstimateScrollBarDimensions) { return computeScrollRangeWithSpanInfo(state); } return super.computeVerticalScrollRange(state); } @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager public int computeHorizontalScrollOffset(RecyclerView.State state) { if (this.mUsingSpansToEstimateScrollBarDimensions) { return computeScrollOffsetWithSpanInfo(state); } return super.computeHorizontalScrollOffset(state); } @Override // androidx.recyclerview.widget.LinearLayoutManager, androidx.recyclerview.widget.RecyclerView.LayoutManager public int computeVerticalScrollOffset(RecyclerView.State state) { if (this.mUsingSpansToEstimateScrollBarDimensions) { return computeScrollOffsetWithSpanInfo(state); } return super.computeVerticalScrollOffset(state); } private int computeScrollRangeWithSpanInfo(RecyclerView.State state) { if (getChildCount() != 0 && state.getItemCount() != 0) { ensureLayoutState(); View findFirstVisibleChildClosestToStart = findFirstVisibleChildClosestToStart(!isSmoothScrollbarEnabled(), true); View findFirstVisibleChildClosestToEnd = findFirstVisibleChildClosestToEnd(!isSmoothScrollbarEnabled(), true); if (findFirstVisibleChildClosestToStart != null && findFirstVisibleChildClosestToEnd != null) { if (!isSmoothScrollbarEnabled()) { return this.mSpanSizeLookup.getCachedSpanGroupIndex(state.getItemCount() - 1, this.mSpanCount) + 1; } int decoratedEnd = this.mOrientationHelper.getDecoratedEnd(findFirstVisibleChildClosestToEnd) - this.mOrientationHelper.getDecoratedStart(findFirstVisibleChildClosestToStart); int cachedSpanGroupIndex = this.mSpanSizeLookup.getCachedSpanGroupIndex(getPosition(findFirstVisibleChildClosestToStart), this.mSpanCount); return (int) ((decoratedEnd / ((this.mSpanSizeLookup.getCachedSpanGroupIndex(getPosition(findFirstVisibleChildClosestToEnd), this.mSpanCount) - cachedSpanGroupIndex) + 1)) * (this.mSpanSizeLookup.getCachedSpanGroupIndex(state.getItemCount() - 1, this.mSpanCount) + 1)); } } return 0; } private int computeScrollOffsetWithSpanInfo(RecyclerView.State state) { int max; if (getChildCount() != 0 && state.getItemCount() != 0) { ensureLayoutState(); boolean isSmoothScrollbarEnabled = isSmoothScrollbarEnabled(); View findFirstVisibleChildClosestToStart = findFirstVisibleChildClosestToStart(!isSmoothScrollbarEnabled, true); View findFirstVisibleChildClosestToEnd = findFirstVisibleChildClosestToEnd(!isSmoothScrollbarEnabled, true); if (findFirstVisibleChildClosestToStart != null && findFirstVisibleChildClosestToEnd != null) { int cachedSpanGroupIndex = this.mSpanSizeLookup.getCachedSpanGroupIndex(getPosition(findFirstVisibleChildClosestToStart), this.mSpanCount); int cachedSpanGroupIndex2 = this.mSpanSizeLookup.getCachedSpanGroupIndex(getPosition(findFirstVisibleChildClosestToEnd), this.mSpanCount); int min = Math.min(cachedSpanGroupIndex, cachedSpanGroupIndex2); int max2 = Math.max(cachedSpanGroupIndex, cachedSpanGroupIndex2); int cachedSpanGroupIndex3 = this.mSpanSizeLookup.getCachedSpanGroupIndex(state.getItemCount() - 1, this.mSpanCount) + 1; if (this.mShouldReverseLayout) { max = Math.max(0, (cachedSpanGroupIndex3 - max2) - 1); } else { max = Math.max(0, min); } if (!isSmoothScrollbarEnabled) { return max; } return Math.round((max * (Math.abs(this.mOrientationHelper.getDecoratedEnd(findFirstVisibleChildClosestToEnd) - this.mOrientationHelper.getDecoratedStart(findFirstVisibleChildClosestToStart)) / ((this.mSpanSizeLookup.getCachedSpanGroupIndex(getPosition(findFirstVisibleChildClosestToEnd), this.mSpanCount) - this.mSpanSizeLookup.getCachedSpanGroupIndex(getPosition(findFirstVisibleChildClosestToStart), this.mSpanCount)) + 1))) + (this.mOrientationHelper.getStartAfterPadding() - this.mOrientationHelper.getDecoratedStart(findFirstVisibleChildClosestToStart))); } } return 0; } /* loaded from: classes2.dex */ public static final class DefaultSpanSizeLookup extends SpanSizeLookup { @Override // androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup public int getSpanSize(int i) { return 1; } @Override // androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup public int getSpanIndex(int i, int i2) { return i % i2; } } /* loaded from: classes2.dex */ public static class LayoutParams extends RecyclerView.LayoutParams { public static final int INVALID_SPAN_ID = -1; int mSpanIndex; int mSpanSize; public int getSpanIndex() { return this.mSpanIndex; } public int getSpanSize() { return this.mSpanSize; } public LayoutParams(Context context, AttributeSet attributeSet) { super(context, attributeSet); this.mSpanIndex = -1; this.mSpanSize = 0; } public LayoutParams(int i, int i2) { super(i, i2); this.mSpanIndex = -1; this.mSpanSize = 0; } public LayoutParams(ViewGroup.MarginLayoutParams marginLayoutParams) { super(marginLayoutParams); this.mSpanIndex = -1; this.mSpanSize = 0; } public LayoutParams(ViewGroup.LayoutParams layoutParams) { super(layoutParams); this.mSpanIndex = -1; this.mSpanSize = 0; } public LayoutParams(RecyclerView.LayoutParams layoutParams) { super(layoutParams); this.mSpanIndex = -1; this.mSpanSize = 0; } } }