diff options
Diffstat (limited to 'src/com/android/launcher3/allapps/AllAppsStore.java')
-rw-r--r-- | src/com/android/launcher3/allapps/AllAppsStore.java | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java index 06af970cfc..e724858a79 100644 --- a/src/com/android/launcher3/allapps/AllAppsStore.java +++ b/src/com/android/launcher3/allapps/AllAppsStore.java @@ -15,24 +15,27 @@ */ package com.android.launcher3.allapps; +import static com.android.launcher3.config.FeatureFlags.ENABLE_ALL_APPS_RV_PREINFLATION; import static com.android.launcher3.model.data.AppInfo.COMPONENT_KEY_COMPARATOR; import static com.android.launcher3.model.data.AppInfo.EMPTY_ARRAY; import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK; -import static com.android.launcher3.testing.shared.TestProtocol.WORK_TAB_MISSING; +import android.content.Context; import android.os.UserHandle; -import android.util.Log; import android.view.View; import android.view.ViewGroup; +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; import com.android.launcher3.model.data.ItemInfo; -import com.android.launcher3.testing.shared.TestProtocol; +import com.android.launcher3.recyclerview.AllAppsRecyclerViewPool; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.PackageUserKey; +import com.android.launcher3.views.ActivityContext; import java.util.ArrayList; import java.util.Arrays; @@ -45,8 +48,10 @@ import java.util.function.Predicate; /** * A utility class to maintain the collection of all apps. + * + * @param <T> The type of the context. */ -public class AllAppsStore { +public class AllAppsStore<T extends Context & ActivityContext> { // Defer updates flag used to defer all apps updates to the next draw. public static final int DEFER_UPDATES_NEXT_DRAW = 1 << 0; @@ -56,7 +61,7 @@ public class AllAppsStore { private PackageUserKey mTempKey = new PackageUserKey(null, null); private AppInfo mTempInfo = new AppInfo(); - private AppInfo[] mApps = EMPTY_ARRAY; + private @NonNull AppInfo[] mApps = EMPTY_ARRAY; private final List<OnUpdateListener> mUpdateListeners = new CopyOnWriteArrayList<>(); private final ArrayList<ViewGroup> mIconContainers = new ArrayList<>(); @@ -64,20 +69,36 @@ public class AllAppsStore { private int mModelFlags; private int mDeferUpdatesFlags = 0; private boolean mUpdatePending = false; + private final AllAppsRecyclerViewPool mAllAppsRecyclerViewPool = new AllAppsRecyclerViewPool(); + + private final T mContext; public AppInfo[] getApps() { return mApps; } + public AllAppsStore(@NonNull T context) { + mContext = context; + } + /** * Sets the current set of apps and sets mapping for {@link PackageUserKey} to Uid for * the current set of apps. */ - public void setApps(AppInfo[] apps, int flags, Map<PackageUserKey, Integer> map) { - mApps = apps; + public void setApps(@Nullable AppInfo[] apps, int flags, Map<PackageUserKey, Integer> map) { + mApps = apps == null ? EMPTY_ARRAY : apps; mModelFlags = flags; notifyUpdate(); mPackageUserKeytoUidMap = map; + // Preinflate all apps RV when apps has changed, which can happen after unlocking screen, + // rotating screen, or downloading/upgrading apps. + if (ENABLE_ALL_APPS_RV_PREINFLATION.get()) { + mAllAppsRecyclerViewPool.preInflateAllAppsViewHolders(mContext); + } + } + + RecycledViewPool getRecyclerViewPool() { + return mAllAppsRecyclerViewPool; } /** @@ -134,9 +155,6 @@ public class AllAppsStore { return; } for (OnUpdateListener listener : mUpdateListeners) { - if (TestProtocol.sDebugTracing) { - Log.d(WORK_TAB_MISSING, "AllAppsStore#notifyUpdate listener: " + listener); - } listener.onAppsUpdated(); } } |