Merge "Double pre-inflate counts if work profile is enabled" into main
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index dabe84d..61ca95b 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -80,6 +80,7 @@
import com.android.launcher3.keyboard.FocusedItemDecorator;
import com.android.launcher3.model.StringCache;
import com.android.launcher3.model.data.ItemInfo;
+import com.android.launcher3.recyclerview.AllAppsRecyclerViewPool;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
@@ -93,7 +94,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
-import java.util.stream.Stream;
/**
* All apps container view with search support for use in a dragging activity.
@@ -623,16 +623,18 @@
private static void setUpCustomRecyclerViewPool(
@NonNull AllAppsRecyclerView mainRecyclerView,
@Nullable AllAppsRecyclerView workRecyclerView,
- @NonNull RecyclerView.RecycledViewPool recycledViewPool) {
+ @NonNull AllAppsRecyclerViewPool recycledViewPool) {
if (!ENABLE_ALL_APPS_RV_PREINFLATION.get()) {
return;
}
+ final boolean hasWorkProfile = workRecyclerView != null;
+ recycledViewPool.setHasWorkProfile(hasWorkProfile);
mainRecyclerView.setRecycledViewPool(recycledViewPool);
if (workRecyclerView != null) {
workRecyclerView.setRecycledViewPool(recycledViewPool);
}
if (ALL_APPS_GONE_VISIBILITY.get()) {
- mainRecyclerView.updatePoolSize();
+ mainRecyclerView.updatePoolSize(hasWorkProfile);
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index cffddfc..b0f13ef 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -95,6 +95,10 @@
}
protected void updatePoolSize() {
+ updatePoolSize(false);
+ }
+
+ void updatePoolSize(boolean hasWorkProfile) {
DeviceProfile grid = ActivityContext.lookupContext(getContext()).getDeviceProfile();
RecyclerView.RecycledViewPool pool = getRecycledViewPool();
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH, 1);
@@ -111,6 +115,9 @@
maxPoolSizeForAppIcons +=
PREINFLATE_ICONS_ROW_COUNT * grid.numShownAllAppsColumns + EXTRA_ICONS_COUNT;
}
+ if (hasWorkProfile) {
+ maxPoolSizeForAppIcons *= 2;
+ }
pool.setMaxRecycledViews(
AllAppsGridAdapter.VIEW_TYPE_ICON, maxPoolSizeForAppIcons);
}
diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java
index 7867f44..9f6e0fc 100644
--- a/src/com/android/launcher3/allapps/AllAppsStore.java
+++ b/src/com/android/launcher3/allapps/AllAppsStore.java
@@ -27,7 +27,6 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.recyclerview.widget.RecyclerView.RecycledViewPool;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.model.data.AppInfo;
@@ -110,7 +109,7 @@
}
}
- RecycledViewPool getRecyclerViewPool() {
+ AllAppsRecyclerViewPool getRecyclerViewPool() {
return mAllAppsRecyclerViewPool;
}
diff --git a/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt b/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt
index 1d71805..45174a7 100644
--- a/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt
+++ b/src/com/android/launcher3/recyclerview/AllAppsRecyclerViewPool.kt
@@ -40,6 +40,8 @@
private var future: Future<Void>? = null
+ var hasWorkProfile = false
+
/**
* Preinflate app icons. If all apps RV cannot be scrolled down, we don't need to preinflate.
*/
@@ -95,6 +97,9 @@
val grid = ActivityContext.lookupContext<T>(context).deviceProfile
targetPreinflateCount += grid.maxAllAppsRowCount * grid.numShownAllAppsColumns
}
+ if (hasWorkProfile) {
+ targetPreinflateCount *= 2
+ }
val existingPreinflateCount = getRecycledViewCount(BaseAllAppsAdapter.VIEW_TYPE_ICON)
return targetPreinflateCount - existingPreinflateCount
}