diff options
author | Adam Cohen <adamcohen@google.com> | 2012-06-06 14:10:04 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2012-06-06 15:00:45 -0700 |
commit | 3d50932a93dd367537db3548bde29d1380b371c0 (patch) | |
tree | 28164308e8f356646ddf89296abec14cb1049e49 | |
parent | 5b7fcb7a8bee95b5c59dd296c6b022e3d1c55102 (diff) | |
download | android_packages_apps_Trebuchet-3d50932a93dd367537db3548bde29d1380b371c0.tar.gz android_packages_apps_Trebuchet-3d50932a93dd367537db3548bde29d1380b371c0.tar.bz2 android_packages_apps_Trebuchet-3d50932a93dd367537db3548bde29d1380b371c0.zip |
Fixing ConcurrentModificationException (issue 6619380)
Change-Id: I49d293a79a463d129e829f823d6b213f3d5ffcf4
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 31 | ||||
-rw-r--r-- | src/com/android/launcher2/LauncherModel.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 23 |
3 files changed, 24 insertions, 34 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index fb29a4131..d7dd6480a 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -690,41 +690,13 @@ public final class Launcher extends Activity // Consequently, the widgets will be inflated in the orientation of the foreground activity // (framework issue). On resuming, we ensure that any widgets are inflated for the current // orientation. - reinflateWidgetsIfNecessary(); + getWorkspace().reinflateWidgetsIfNecessary(); // Again, as with the above scenario, it's possible that one or more of the global icons // were updated in the wrong orientation. updateGlobalIcons(); } - void reinflateWidgetsIfNecessary() { - for (LauncherAppWidgetInfo info: LauncherModel.getWidgets()) { - LauncherAppWidgetHostView lahv = (LauncherAppWidgetHostView) info.hostView; - if (lahv != null && lahv.orientationChangedSincedInflation()) { - AppWidgetProviderInfo pInfo = lahv.getAppWidgetInfo(); - - Workspace workspace = getWorkspace(); - CellLayout parent = workspace.getParentCellLayoutForView(lahv); - - // It's possible this AppWidgetHostView is associated with a prior Launcher instance - // in which case it will not have a parent in the current hierarchy (ie. after rotation). - // In this case we will be re-inflating the widgets anyhow, so it's not a problem. - if (parent != null) { - // Remove the current widget which is inflated with the wrong orientation - parent.removeView(lahv); - // Re-inflate the widget using the correct orientation - AppWidgetHostView widget = mAppWidgetHost.createView(this, info.appWidgetId, pInfo); - - // Add the new widget back - widget.setTag(info); - info.hostView = widget; - getWorkspace().addInScreen(widget, info.container, info.screen, - info.cellX, info.cellY, info.spanX, info.spanY); - } - } - } - } - @Override protected void onPause() { // NOTE: We want all transitions from launcher to act as if the wallpaper were enabled @@ -3230,7 +3202,6 @@ public final class Launcher extends Activity item.hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo); - item.hostView.setAppWidget(appWidgetId, appWidgetInfo); item.hostView.setTag(item); item.onBindAppWidget(this); diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index 1b17ef952..fc1a26d4b 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -377,10 +377,6 @@ public class LauncherModel extends BroadcastReceiver { return items; } - static ArrayList<LauncherAppWidgetInfo> getWidgets() { - return sAppWidgets; - } - /** * Find a folder in the db, creating the FolderInfo if necessary, and adding it to folderList. */ diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index ba518890e..8b9662b3b 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -670,6 +670,29 @@ public class Workspace extends SmoothPagedView return super.onInterceptTouchEvent(ev); } + protected void reinflateWidgetsIfNecessary() { + final int clCount = getChildCount(); + for (int i = 0; i < clCount; i++) { + CellLayout cl = (CellLayout) getChildAt(i); + ShortcutAndWidgetContainer swc = cl.getShortcutsAndWidgets(); + final int itemCount = swc.getChildCount(); + for (int j = 0; j < itemCount; j++) { + View v = swc.getChildAt(j); + + if (v.getTag() instanceof LauncherAppWidgetInfo) { + LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) v.getTag(); + LauncherAppWidgetHostView lahv = (LauncherAppWidgetHostView) info.hostView; + if (lahv != null && lahv.orientationChangedSincedInflation()) { + mLauncher.removeAppWidget(info); + // Remove the current widget which is inflated with the wrong orientation + cl.removeView(lahv); + mLauncher.bindAppWidget(info); + } + } + } + } + } + @Override protected void determineScrollingStart(MotionEvent ev) { if (isSmall()) return; |