am e8375ef5: Merge "Prevent multiple size changed callbacks to widgets whenever we reload the workspace." into jb-dev
* commit 'e8375ef55e7d196b98894f5cf6f479abc99188f5': Prevent multiple size changed callbacks to widgets whenever we reload the workspace.
This commit is contained in:
commit
df7f660177
2 files changed
+22
-6
No files matched your search
@@ -1129,8 +1129,7 @@ public final class Launcher extends Activity
|
|||||||
|
|
||||||
launcherInfo.hostView.setTag(launcherInfo);
|
launcherInfo.hostView.setTag(launcherInfo);
|
||||||
launcherInfo.hostView.setVisibility(View.VISIBLE);
|
launcherInfo.hostView.setVisibility(View.VISIBLE);
|
||||||
AppWidgetResizeFrame.updateWidgetSizeRanges(launcherInfo.hostView,
|
launcherInfo.notifyWidgetSizeChanged(this);
|
||||||
this, launcherInfo.spanX, launcherInfo.spanY);
|
|
||||||
mWorkspace.addInScreen(launcherInfo.hostView, container, screen, cellXY[0], cellXY[1],
|
mWorkspace.addInScreen(launcherInfo.hostView, container, screen, cellXY[0], cellXY[1],
|
||||||
launcherInfo.spanX, launcherInfo.spanY, isWorkspaceLocked());
|
launcherInfo.spanX, launcherInfo.spanY, isWorkspaceLocked());
|
||||||
|
|
||||||
@@ -3160,17 +3159,14 @@ public final class Launcher extends Activity
|
|||||||
|
|
||||||
item.hostView.setAppWidget(appWidgetId, appWidgetInfo);
|
item.hostView.setAppWidget(appWidgetId, appWidgetInfo);
|
||||||
item.hostView.setTag(item);
|
item.hostView.setTag(item);
|
||||||
|
item.onBindAppWidget(this);
|
||||||
|
|
||||||
workspace.addInScreen(item.hostView, item.container, item.screen, item.cellX,
|
workspace.addInScreen(item.hostView, item.container, item.screen, item.cellX,
|
||||||
item.cellY, item.spanX, item.spanY, false);
|
item.cellY, item.spanX, item.spanY, false);
|
||||||
|
|
||||||
addWidgetToAutoAdvanceIfNeeded(item.hostView, appWidgetInfo);
|
addWidgetToAutoAdvanceIfNeeded(item.hostView, appWidgetInfo);
|
||||||
|
|
||||||
workspace.requestLayout();
|
workspace.requestLayout();
|
||||||
|
|
||||||
AppWidgetResizeFrame.updateWidgetSizeRanges(item.hostView,
|
|
||||||
this, item.spanX, item.spanY);
|
|
||||||
|
|
||||||
if (DEBUG_WIDGETS) {
|
if (DEBUG_WIDGETS) {
|
||||||
Log.d(TAG, "bound widget id="+item.appWidgetId+" in "
|
Log.d(TAG, "bound widget id="+item.appWidgetId+" in "
|
||||||
+ (SystemClock.uptimeMillis()-start) + "ms");
|
+ (SystemClock.uptimeMillis()-start) + "ms");
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ class LauncherAppWidgetInfo extends ItemInfo {
|
|||||||
int minWidth = -1;
|
int minWidth = -1;
|
||||||
int minHeight = -1;
|
int minHeight = -1;
|
||||||
|
|
||||||
|
private boolean mHasNotifiedInitialWidgetSizeChanged;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View that holds this widget after it's been created. This view isn't created
|
* View that holds this widget after it's been created. This view isn't created
|
||||||
* until Launcher knows it's needed.
|
* until Launcher knows it's needed.
|
||||||
@@ -65,6 +67,24 @@ class LauncherAppWidgetInfo extends ItemInfo {
|
|||||||
values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "AppWidget(id=" + Integer.toString(appWidgetId) + ")";
|
return "AppWidget(id=" + Integer.toString(appWidgetId) + ")";
|
||||||
|
|||||||
Reference in new issue
Block a user