Update apps icon in prediction apps row when apps are updated

Fix: 70717710

Change-Id: I89540893ca3c8c4eae3f47bc07c3deade135e5c3
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index a40f8b3..d05b556 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -165,6 +165,7 @@
         }
         onAppsUpdated();
         mSearchUiManager.refreshSearchResult();
+        mHeader.onAppsUpdated();
     }
 
     /**
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java
index e4f8ad3..2391768 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderView.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java
@@ -219,6 +219,9 @@
         p.y = getTop() - mCurrentRV.getTop() - mParent.getTop();
     }
 
+    public void onAppsUpdated() {
+        mPredictionRow.onAppsUpdated();
+    }
 }
 
 
diff --git a/src/com/android/launcher3/allapps/PredictionRowView.java b/src/com/android/launcher3/allapps/PredictionRowView.java
index e834ff4..bc934dd 100644
--- a/src/com/android/launcher3/allapps/PredictionRowView.java
+++ b/src/com/android/launcher3/allapps/PredictionRowView.java
@@ -105,7 +105,7 @@
     public void setNumAppsPerRow(int numPredictedAppsPerRow) {
         if (mNumPredictedAppsPerRow != numPredictedAppsPerRow) {
             mNumPredictedAppsPerRow = numPredictedAppsPerRow;
-            onAppsUpdated();
+            onPredictionsUpdated();
         }
     }
 
@@ -120,7 +120,7 @@
      * Sets the current set of predicted apps.
      *
      * This can be called before we get the full set of applications, we should merge the results
-     * only in onAppsUpdated() which is idempotent.
+     * only in onPredictionsUpdated() which is idempotent.
      *
      * If the number of predicted apps is the same as the previous list of predicted apps,
      * we can optimize by swapping them in place.
@@ -130,10 +130,10 @@
         mPredictedAppComponents.addAll(apps);
         mPredictedApps.clear();
         mPredictedApps.addAll(processPredictedAppComponents(mPredictedAppComponents));
-        onAppsUpdated();
+        onPredictionsUpdated();
     }
 
-    private void onAppsUpdated() {
+    private void onPredictionsUpdated() {
         int childCountBefore = getChildCount();
         if (getChildCount() != mNumPredictedAppsPerRow) {
             while (getChildCount() > mNumPredictedAppsPerRow) {
@@ -170,6 +170,24 @@
         }
     }
 
+    /**
+     * Refreshes the app icons in the row view, while preserving the same set of predictions.
+     */
+    public void onAppsUpdated() {
+        for (int i = 0; i < getChildCount(); i++) {
+            View child = getChildAt(i);
+            if (!(child instanceof BubbleTextView)) {
+                continue;
+            }
+            if (i >= mPredictedApps.size()) {
+                break;
+            }
+            BubbleTextView icon = (BubbleTextView) getChildAt(i);
+            icon.reset();
+            icon.applyFromApplicationInfo(mPredictedApps.get(i));
+        }
+    }
+
     private List<AppInfo> processPredictedAppComponents(
             List<ComponentKeyMapper<AppInfo>> components) {
         if (mComponentToAppMap.isEmpty()) {