From da25da3d557177febb9c7afb78e04b1ef4a45f17 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 15 May 2015 16:30:08 -0700 Subject: [PATCH] Ensure that we have a reasonable cache size for AllApps. Change-Id: Ic0cb5ec2911567102227748cd9d2c1d8297fe105 --- src/com/android/launcher3/AppsContainerRecyclerView.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/com/android/launcher3/AppsContainerRecyclerView.java b/src/com/android/launcher3/AppsContainerRecyclerView.java index bd7f645fc3..31942b36d4 100644 --- a/src/com/android/launcher3/AppsContainerRecyclerView.java +++ b/src/com/android/launcher3/AppsContainerRecyclerView.java @@ -128,6 +128,14 @@ public class AppsContainerRecyclerView extends BaseContainerRecyclerView { public void setNumAppsPerRow(int numAppsPerRow, int numPredictedAppsPerRow) { mNumAppsPerRow = numAppsPerRow; mNumPredictedAppsPerRow = numPredictedAppsPerRow; + + DeviceProfile grid = LauncherAppState.getInstance().getDynamicGrid().getDeviceProfile(); + RecyclerView.RecycledViewPool pool = getRecycledViewPool(); + int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx); + pool.setMaxRecycledViews(AppsGridAdapter.PREDICTION_BAR_SPACER_TYPE, 1); + pool.setMaxRecycledViews(AppsGridAdapter.EMPTY_VIEW_TYPE, 1); + pool.setMaxRecycledViews(AppsGridAdapter.ICON_VIEW_TYPE, approxRows * mNumAppsPerRow); + pool.setMaxRecycledViews(AppsGridAdapter.SECTION_BREAK_VIEW_TYPE, approxRows); } public void updateBackgroundPadding(Drawable background) {