diff --git a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java index 4c0e0d595f..35fa7a42cc 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java +++ b/src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java @@ -173,11 +173,12 @@ public class WidgetsRecyclerView extends FastScrollRecyclerView implements OnIte @Override protected int getItemsHeight(int untilIndex) { // Initialize cache - int childCount = Math.min(getChildCount(), getAdapter().getItemCount()); + int childCount = getChildCount(); int startPosition; if (childCount > 0 && ((startPosition = getChildAdapterPosition(getChildAt(0))) != NO_POSITION)) { - for (int i = 0; i < childCount; i++) { + int loopCount = Math.min(getChildCount(), getAdapter().getItemCount() - startPosition); + for (int i = 0; i < loopCount; i++) { mCachedSizes.put( mAdapter.getItemViewType(startPosition + i), getChildAt(i).getMeasuredHeight());