am 21a170b2: Fix for stuck widget (issue 6557954)
* commit '21a170b2e17621583f2800d5611459a0a939f560': Fix for stuck widget (issue 6557954)
This commit is contained in:
@@ -299,8 +299,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
|||||||
private Runnable mInflateWidgetRunnable = null;
|
private Runnable mInflateWidgetRunnable = null;
|
||||||
private Runnable mBindWidgetRunnable = null;
|
private Runnable mBindWidgetRunnable = null;
|
||||||
static final int WIDGET_NO_CLEANUP_REQUIRED = -1;
|
static final int WIDGET_NO_CLEANUP_REQUIRED = -1;
|
||||||
static final int WIDGET_BOUND = 0;
|
static final int WIDGET_PRELOAD_PENDING = 0;
|
||||||
static final int WIDGET_INFLATED = 1;
|
static final int WIDGET_BOUND = 1;
|
||||||
|
static final int WIDGET_INFLATED = 2;
|
||||||
int mWidgetCleanupState = WIDGET_NO_CLEANUP_REQUIRED;
|
int mWidgetCleanupState = WIDGET_NO_CLEANUP_REQUIRED;
|
||||||
int mWidgetLoadingId = -1;
|
int mWidgetLoadingId = -1;
|
||||||
PendingAddWidgetInfo mCreateWidgetInfo = null;
|
PendingAddWidgetInfo mCreateWidgetInfo = null;
|
||||||
@@ -654,6 +655,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mWidgetCleanupState = WIDGET_PRELOAD_PENDING;
|
||||||
mBindWidgetRunnable = new Runnable() {
|
mBindWidgetRunnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -716,17 +718,29 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
|||||||
// If the widget was not added, we may need to do further cleanup.
|
// If the widget was not added, we may need to do further cleanup.
|
||||||
PendingAddWidgetInfo info = mCreateWidgetInfo;
|
PendingAddWidgetInfo info = mCreateWidgetInfo;
|
||||||
mCreateWidgetInfo = null;
|
mCreateWidgetInfo = null;
|
||||||
// First step was to allocate a widget id, revert that.
|
|
||||||
if ((mWidgetCleanupState == WIDGET_BOUND || mWidgetCleanupState == WIDGET_INFLATED) &&
|
if (mWidgetCleanupState == WIDGET_PRELOAD_PENDING) {
|
||||||
mWidgetLoadingId != -1) {
|
Log.d(TAG, " 6557954 Cleaning up widget, remove preload callbacks");
|
||||||
Log.d(TAG, " 6557954 Cleaning up widget, delete widget id");
|
// We never did any preloading, so just remove pending callbacks to do so
|
||||||
mLauncher.getAppWidgetHost().deleteAppWidgetId(mWidgetLoadingId);
|
removeCallbacks(mBindWidgetRunnable);
|
||||||
}
|
removeCallbacks(mInflateWidgetRunnable);
|
||||||
if (mWidgetCleanupState == WIDGET_BOUND) {
|
} else if (mWidgetCleanupState == WIDGET_BOUND) {
|
||||||
// We never actually inflated the widget, so remove the callback to do so.
|
// Delete the widget id which was allocated
|
||||||
|
if (mWidgetLoadingId != -1) {
|
||||||
|
Log.d(TAG, " 6557954 Cleaning up widget, delete widget id");
|
||||||
|
mLauncher.getAppWidgetHost().deleteAppWidgetId(mWidgetLoadingId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We never got around to inflating the widget, so remove the callback to do so.
|
||||||
Log.d(TAG, " 6557954 Cleaning up widget, remove callbacks");
|
Log.d(TAG, " 6557954 Cleaning up widget, remove callbacks");
|
||||||
removeCallbacks(mInflateWidgetRunnable);
|
removeCallbacks(mInflateWidgetRunnable);
|
||||||
} else if (mWidgetCleanupState == WIDGET_INFLATED) {
|
} else if (mWidgetCleanupState == WIDGET_INFLATED) {
|
||||||
|
// Delete the widget id which was allocated
|
||||||
|
if (mWidgetLoadingId != -1) {
|
||||||
|
Log.d(TAG, " 6557954 Cleaning up widget, delete widget id");
|
||||||
|
mLauncher.getAppWidgetHost().deleteAppWidgetId(mWidgetLoadingId);
|
||||||
|
}
|
||||||
|
|
||||||
// The widget was inflated and added to the DragLayer -- remove it.
|
// The widget was inflated and added to the DragLayer -- remove it.
|
||||||
Log.d(TAG, " 6557954 Cleaning up widget, remove inflated widget from draglayer");
|
Log.d(TAG, " 6557954 Cleaning up widget, remove inflated widget from draglayer");
|
||||||
AppWidgetHostView widget = info.boundWidget;
|
AppWidgetHostView widget = info.boundWidget;
|
||||||
|
|||||||
Reference in New Issue
Block a user