Merge "Prevent multiple size changed callbacks to widgets whenever we reload the workspace." into jb-dev
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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) + ")";
|
||||
|
||||
Reference in New Issue
Block a user