diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-02-03 01:29:56 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-02-03 01:29:56 +0000 |
commit | b5c5e27ab6bbbaf69203044bab7b9af61efd79dd (patch) | |
tree | d51ac9fb3e2a72b592dde8472dcf2bae54adce13 /src/com/android/launcher3/allapps/AllAppsStore.java | |
parent | 041c765ca5ee78a8b8c21db1882740b81439c1eb (diff) | |
parent | 808fc1574781a8be6700feb728c9ee65426722a8 (diff) | |
download | Launcher3-b5c5e27ab6bbbaf69203044bab7b9af61efd79dd.tar.gz |
Merge "Snap for 11400057 from ded14cc2110e39408f74abac8a83e0a0f16608d2 to simpleperf-release" into simpleperf-releasesimpleperf-release
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(); } } |