Re-updating widget set in customization drawer when applications are changed.
- This prevents a particular crash where a widget that no longer exists is queried for it's app icon
Change-Id: I84b450d37c01d995bb249aae8cdf8e5c032883cf
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index 03c4bce..62e5496 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -182,8 +182,9 @@
public void setApps(ArrayList<ApplicationInfo> list) {
mApps = list;
Collections.sort(mApps, LauncherModel.APP_NAME_COMPARATOR);
- mPageViewIconCache.clear();
- invalidatePageData();
+
+ // Update the widgets/shortcuts to reflect changes in the set of available apps
+ update();
}
/**
@@ -207,7 +208,9 @@
*/
public void addApps(ArrayList<ApplicationInfo> list) {
addAppsWithoutInvalidate(list);
- invalidatePageData();
+
+ // Update the widgets/shortcuts to reflect changes in the set of available apps
+ update();
}
/**
@@ -232,7 +235,9 @@
*/
public void removeApps(ArrayList<ApplicationInfo> list) {
removeAppsWithoutInvalidate(list);
- invalidatePageData();
+
+ // Update the widgets/shortcuts to reflect changes in the set of available apps
+ update();
}
/**
@@ -245,7 +250,9 @@
// place in the list.
removeAppsWithoutInvalidate(list);
addAppsWithoutInvalidate(list);
- invalidatePageData();
+
+ // Update the widgets/shortcuts to reflect changes in the set of available apps
+ update();
}
/**
@@ -554,7 +561,8 @@
Drawable icon = null;
if (info.icon > 0) {
icon = packageManager.getDrawable(packageName, info.icon, null);
- } else {
+ }
+ if (icon == null) {
icon = resources.getDrawable(R.drawable.ic_launcher_application);
}
background.getPadding(tmpRect);
diff --git a/src/com/android/launcher2/DimmableAppWidgetHostView.java b/src/com/android/launcher2/DimmableAppWidgetHostView.java
index 7a1d4f9..b5ec8cd 100644
--- a/src/com/android/launcher2/DimmableAppWidgetHostView.java
+++ b/src/com/android/launcher2/DimmableAppWidgetHostView.java
@@ -144,4 +144,4 @@
super.dispatchDraw(canvas);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index da1393c..7eb0256 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -3071,8 +3071,9 @@
*/
public void bindPackagesUpdated() {
// update the customization drawer contents
- if (mCustomizePagedView != null)
+ if (mCustomizePagedView != null) {
mCustomizePagedView.update();
+ }
}
/**