From 4926ebfe6d6e6c7b65923521ec799daf414fec5d Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Tue, 25 Apr 2017 14:13:20 -0700 Subject: [PATCH] Fix updateIconBadges() in All Apps Instead of notifyItemChanged(), we iterate over children of the RecyclerView itself and call applyBadgeState() on affected icons. This is the same logic we do for the workspace. Issues this fixes: - Icons flash when dismissing notifications - Badge reappears on the icon while popup is open Change-Id: I5c69d5c6bd47630c0241666b5f7f6f7ca97118f9 --- .../launcher3/allapps/AllAppsContainerView.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index cc5fa8ce15..2c7d156297 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -37,6 +37,7 @@ import android.view.ViewGroup; import com.android.launcher3.AppInfo; import com.android.launcher3.BaseContainerView; +import com.android.launcher3.BubbleTextView; import com.android.launcher3.DeleteDropTarget; import com.android.launcher3.DeviceProfile; import com.android.launcher3.DragSource; @@ -485,11 +486,15 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc public void updateIconBadges(Set updatedBadges) { final PackageUserKey packageUserKey = new PackageUserKey(null, null); - for (AlphabeticalAppsList.AdapterItem app : mApps.getAdapterItems()) { - if (app.appInfo != null && packageUserKey.updateFromItemInfo(app.appInfo)) { - if (updatedBadges.contains(packageUserKey)) { - mAdapter.notifyItemChanged(app.position); - } + final int n = mAppsRecyclerView.getChildCount(); + for (int i = 0; i < n; i++) { + View child = mAppsRecyclerView.getChildAt(i); + if (!(child instanceof BubbleTextView) || !(child.getTag() instanceof ItemInfo)) { + continue; + } + ItemInfo info = (ItemInfo) child.getTag(); + if (packageUserKey.updateFromItemInfo(info) && updatedBadges.contains(packageUserKey)) { + ((BubbleTextView) child).applyBadgeState(info, true /* animate */); } } }