diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2018-02-07 12:56:30 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2018-02-07 15:55:58 -0800 |
commit | 60180b049eae9d23658456048d5af108f9a47271 (patch) | |
tree | 5a2bcbcd41b1dd33e8ecc7993a226b35ab079ab4 /src/com/android/launcher3/allapps/AllAppsStore.java | |
parent | 168ca694f9eb7166280763af9942dc5392c1602d (diff) | |
download | android_packages_apps_Trebuchet-60180b049eae9d23658456048d5af108f9a47271.tar.gz android_packages_apps_Trebuchet-60180b049eae9d23658456048d5af108f9a47271.tar.bz2 android_packages_apps_Trebuchet-60180b049eae9d23658456048d5af108f9a47271.zip |
Deferring all app updates until the pending executor is complete.
We were only deferring full apps binds and not partial updates which could cause
the model to go out of sync with Launcher.
Bug: 72051234
Change-Id: I20db0e86aadd1e6a518237026f6dfb03e469eb87
Diffstat (limited to 'src/com/android/launcher3/allapps/AllAppsStore.java')
-rw-r--r-- | src/com/android/launcher3/allapps/AllAppsStore.java | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java index 846b6a99c..dc3489290 100644 --- a/src/com/android/launcher3/allapps/AllAppsStore.java +++ b/src/com/android/launcher3/allapps/AllAppsStore.java @@ -20,22 +20,30 @@ import android.view.ViewGroup; import com.android.launcher3.AppInfo; import com.android.launcher3.BubbleTextView; +import com.android.launcher3.ItemInfo; +import com.android.launcher3.PromiseAppInfo; import com.android.launcher3.util.ComponentKey; +import com.android.launcher3.util.PackageUserKey; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; +import java.util.Set; /** * A utility class to maintain the collection of all apps. */ public class AllAppsStore { + private PackageUserKey mTempKey = new PackageUserKey(null, null); private final HashMap<ComponentKey, AppInfo> mComponentToAppMap = new HashMap<>(); private final List<OnUpdateListener> mUpdateListeners = new ArrayList<>(); private final ArrayList<ViewGroup> mIconContainers = new ArrayList<>(); + private boolean mDeferUpdates = false; + private boolean mUpdatePending = false; + public Collection<AppInfo> getApps() { return mComponentToAppMap.values(); } @@ -52,6 +60,17 @@ public class AllAppsStore { return mComponentToAppMap.get(key); } + public void setDeferUpdates(boolean deferUpdates) { + if (mDeferUpdates != deferUpdates) { + mDeferUpdates = deferUpdates; + + if (!mDeferUpdates && mUpdatePending) { + notifyUpdate(); + mUpdatePending = false; + } + } + } + /** * Adds or updates existing apps in the list */ @@ -74,6 +93,10 @@ public class AllAppsStore { private void notifyUpdate() { + if (mDeferUpdates) { + mUpdatePending = true; + return; + } int count = mUpdateListeners.size(); for (int i = 0; i < count; i++) { mUpdateListeners.get(i).onAppsUpdated(); @@ -98,7 +121,26 @@ public class AllAppsStore { mIconContainers.remove(container); } - public void updateAllIcons(IconAction action) { + public void updateIconBadges(Set<PackageUserKey> updatedBadges) { + updateAllIcons((child) -> { + if (child.getTag() instanceof ItemInfo) { + ItemInfo info = (ItemInfo) child.getTag(); + if (mTempKey.updateFromItemInfo(info) && updatedBadges.contains(mTempKey)) { + child.applyBadgeState(info, true /* animate */); + } + } + }); + } + + public void updatePromiseAppProgress(PromiseAppInfo app) { + updateAllIcons((child) -> { + if (child.getTag() == app) { + child.applyProgressLevel(app.level); + } + }); + } + + private void updateAllIcons(IconAction action) { for (int i = mIconContainers.size() - 1; i >= 0; i--) { ViewGroup parent = mIconContainers.get(i); int childCount = parent.getChildCount(); |