diff options
author | Adam Cohen <adamcohen@google.com> | 2012-06-05 16:12:40 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-06-05 16:12:40 -0700 |
commit | ff4714f3266d18075f58b6bda7e38d248bcd63ed (patch) | |
tree | 7d76263e04e3726f1e9207a44cb3bea65a53f111 | |
parent | 3e95341fec02b877ee2b97eb03d4a10aa501efb1 (diff) | |
parent | 5637b87d8b71f2af1794abcd980d9d7ffacb7333 (diff) | |
download | android_packages_apps_Trebuchet-ff4714f3266d18075f58b6bda7e38d248bcd63ed.tar.gz android_packages_apps_Trebuchet-ff4714f3266d18075f58b6bda7e38d248bcd63ed.tar.bz2 android_packages_apps_Trebuchet-ff4714f3266d18075f58b6bda7e38d248bcd63ed.zip |
am 5637b87d: Fix workaround for crashing on rotation. (Bug 6611883)
* commit '5637b87d8b71f2af1794abcd980d9d7ffacb7333':
Fix workaround for crashing on rotation. (Bug 6611883)
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 105d9436b..fb29a4131 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -703,17 +703,24 @@ public final class Launcher extends Activity if (lahv != null && lahv.orientationChangedSincedInflation()) { AppWidgetProviderInfo pInfo = lahv.getAppWidgetInfo(); - // Remove the current widget which is inflated with the wrong orientation - CellLayout cl = getWorkspace().getParentCellLayoutForView(lahv); - if (cl != null) cl.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); + 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); + } } } } |