Fixing bug 5011917 - clearing refernce to old folders from FolderInfo
-> Also, ensured that unbind() gets called on all ItemInfos on rotate
Change-Id: I869b68fcae5c66702ec204596f5ecabdc7a32df7
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 33a86a9..5e500ba 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -221,8 +221,6 @@
private static LocaleConfiguration sLocaleConfiguration = null;
- private ArrayList<ItemInfo> mDesktopItems = new ArrayList<ItemInfo>();
-
private static HashMap<Long, FolderInfo> sFolders = new HashMap<Long, FolderInfo>();
// Hotseats (quick-launch icons next to AllApps)
@@ -1098,8 +1096,6 @@
screen, cellXY[0], cellXY[1], false);
if (!mRestoring) {
- mDesktopItems.add(launcherInfo);
-
// Perform actual inflation because we're live
launcherInfo.hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
@@ -1228,7 +1224,6 @@
}
public void removeAppWidget(LauncherAppWidgetInfo launcherInfo) {
- mDesktopItems.remove(launcherInfo);
removeWidgetToAutoAdvance(launcherInfo.hostView);
launcherInfo.hostView = null;
}
@@ -1359,7 +1354,7 @@
TextKeyListener.getInstance().release();
- unbindDesktopItems();
+ unbindWorkspaceItems();
getContentResolver().unregisterContentObserver(mWidgetObserver);
unregisterReceiver(mCloseSystemDialogsReceiver);
@@ -1743,11 +1738,8 @@
* Go through the and disconnect any of the callbacks in the drawables and the views or we
* leak the previous Home screen on orientation change.
*/
- private void unbindDesktopItems() {
- for (ItemInfo item: mDesktopItems) {
- item.unbind();
- }
- mDesktopItems.clear();
+ private void unbindWorkspaceItems() {
+ LauncherModel.unbindWorkspaceItems();
}
/**
@@ -3016,9 +3008,8 @@
});
}
- // This wasn't being called before which resulted in a leak of AppWidgetHostViews (through
- // mDesktopItems -> AppWidgetInfo -> hostView).
- unbindDesktopItems();
+ // This wasn't being called before which resulted in a leak of AppWidgetHostViews
+ unbindWorkspaceItems();
}
/**
@@ -3034,7 +3025,6 @@
for (int i=start; i<end; i++) {
final ItemInfo item = shortcuts.get(i);
- mDesktopItems.add(item);
switch (item.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
@@ -3096,8 +3086,6 @@
workspace.requestLayout();
- mDesktopItems.add(item);
-
if (DEBUG_WIDGETS) {
Log.d(TAG, "bound widget id="+item.appWidgetId+" in "
+ (SystemClock.uptimeMillis()-start) + "ms");
@@ -3269,7 +3257,6 @@
Log.d(TAG, "mRestoring=" + mRestoring);
Log.d(TAG, "mWaitingForResult=" + mWaitingForResult);
Log.d(TAG, "mSavedInstanceState=" + mSavedInstanceState);
- Log.d(TAG, "mDesktopItems.size=" + mDesktopItems.size());
Log.d(TAG, "sFolders.size=" + sFolders.size());
mModel.dumpState();