diff options
author | Winson Chung <winsonc@google.com> | 2012-05-16 14:48:18 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-05-16 14:48:18 -0700 |
commit | e8375ef55e7d196b98894f5cf6f479abc99188f5 (patch) | |
tree | 9a82670d98999a1f22c2ff2d35ef17bc02160bc6 /src/com | |
parent | 9218d8118926eaafe010daa222b6b0f19ce5ab66 (diff) | |
parent | 211bac3cd89b26bda4ff52df984731d11156dc38 (diff) | |
download | packages_apps_trebuchet-e8375ef55e7d196b98894f5cf6f479abc99188f5.zip packages_apps_trebuchet-e8375ef55e7d196b98894f5cf6f479abc99188f5.tar.gz packages_apps_trebuchet-e8375ef55e7d196b98894f5cf6f479abc99188f5.tar.bz2 |
Merge "Prevent multiple size changed callbacks to widgets whenever we reload the workspace." into jb-dev
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher2/LauncherAppWidgetInfo.java | 20 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 2e7caff..91184c9 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -1129,8 +1129,7 @@ public final class Launcher extends Activity launcherInfo.hostView.setTag(launcherInfo); launcherInfo.hostView.setVisibility(View.VISIBLE); - AppWidgetResizeFrame.updateWidgetSizeRanges(launcherInfo.hostView, - this, launcherInfo.spanX, launcherInfo.spanY); + launcherInfo.notifyWidgetSizeChanged(this); mWorkspace.addInScreen(launcherInfo.hostView, container, screen, cellXY[0], cellXY[1], launcherInfo.spanX, launcherInfo.spanY, isWorkspaceLocked()); @@ -3160,17 +3159,14 @@ public final class Launcher extends Activity item.hostView.setAppWidget(appWidgetId, appWidgetInfo); item.hostView.setTag(item); + item.onBindAppWidget(this); workspace.addInScreen(item.hostView, item.container, item.screen, item.cellX, item.cellY, item.spanX, item.spanY, false); - addWidgetToAutoAdvanceIfNeeded(item.hostView, appWidgetInfo); workspace.requestLayout(); - AppWidgetResizeFrame.updateWidgetSizeRanges(item.hostView, - this, item.spanX, item.spanY); - if (DEBUG_WIDGETS) { Log.d(TAG, "bound widget id="+item.appWidgetId+" in " + (SystemClock.uptimeMillis()-start) + "ms"); diff --git a/src/com/android/launcher2/LauncherAppWidgetInfo.java b/src/com/android/launcher2/LauncherAppWidgetInfo.java index e5b9473..f001b2b 100644 --- a/src/com/android/launcher2/LauncherAppWidgetInfo.java +++ b/src/com/android/launcher2/LauncherAppWidgetInfo.java @@ -42,6 +42,8 @@ class LauncherAppWidgetInfo extends ItemInfo { int minWidth = -1; int minHeight = -1; + private boolean mHasNotifiedInitialWidgetSizeChanged; + /** * View that holds this widget after it's been created. This view isn't created * until Launcher knows it's needed. @@ -65,6 +67,24 @@ class LauncherAppWidgetInfo extends ItemInfo { values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId); } + /** + * When we bind the widget, we should notify the widget that the size has changed if we have not + * done so already (only really for default workspace widgets). + */ + void onBindAppWidget(Launcher launcher) { + if (!mHasNotifiedInitialWidgetSizeChanged) { + notifyWidgetSizeChanged(launcher); + } + } + + /** + * Trigger an update callback to the widget to notify it that its size has changed. + */ + void notifyWidgetSizeChanged(Launcher launcher) { + AppWidgetResizeFrame.updateWidgetSizeRanges(hostView, launcher, spanX, spanY); + mHasNotifiedInitialWidgetSizeChanged = true; + } + @Override public String toString() { return "AppWidget(id=" + Integer.toString(appWidgetId) + ")"; |