am 05bf644e: Fix memory leak in Launcher

* commit '05bf644e371c9d965ba864cf7dda6515c7cdce91':
  Fix memory leak in Launcher
This commit is contained in:
Michael Jurka
2011-11-30 21:11:18 -08:00
committed by Android Git Automerger
2 changed files with 5 additions and 1 deletions
+1
View File
@@ -2920,6 +2920,7 @@ public final class Launcher extends Activity
final CellLayout layoutParent = (CellLayout) workspace.getChildAt(i);
layoutParent.removeAllViewsInLayout();
}
mWidgetsToAdvance.clear();
if (mHotseat != null) {
mHotseat.resetLayout();
}
+4 -1
View File
@@ -176,12 +176,16 @@ public class LauncherModel extends BroadcastReceiver {
// Ensure that we don't use the same workspace items data structure on the main thread
// by making a copy of workspace items first.
final ArrayList<ItemInfo> workspaceItems = new ArrayList<ItemInfo>(sWorkspaceItems);
final ArrayList<ItemInfo> appWidgets = new ArrayList<ItemInfo>(sAppWidgets);
mHandler.post(new Runnable() {
@Override
public void run() {
for (ItemInfo item : workspaceItems) {
item.unbind();
}
for (ItemInfo item : appWidgets) {
item.unbind();
}
}
});
@@ -1229,7 +1233,6 @@ public class LauncherModel extends BroadcastReceiver {
}
});
// Unbind previously bound workspace items to prevent a leak of AppWidgetHostViews.
final ArrayList<ItemInfo> workspaceItems = unbindWorkspaceItemsOnMainThread();
// Add the items to the workspace.