summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2012-06-05 16:03:36 -0700
committerAdam Cohen <adamcohen@google.com>2012-06-05 16:05:26 -0700
commit5637b87d8b71f2af1794abcd980d9d7ffacb7333 (patch)
tree7d76263e04e3726f1e9207a44cb3bea65a53f111
parent67640c0cbe27e6c83b69070d23ea50c4a6f18447 (diff)
downloadandroid_packages_apps_Trebuchet-5637b87d8b71f2af1794abcd980d9d7ffacb7333.tar.gz
android_packages_apps_Trebuchet-5637b87d8b71f2af1794abcd980d9d7ffacb7333.tar.bz2
android_packages_apps_Trebuchet-5637b87d8b71f2af1794abcd980d9d7ffacb7333.zip
Fix workaround for crashing on rotation. (Bug 6611883)
Change-Id: Iaf9734d156e5aa48f3630f22a42e17d71af37316
-rw-r--r--src/com/android/launcher2/Launcher.java29
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);
+ }
}
}
}