From cb9ab4f3aa04ad60355d119dfedca3052378d8f9 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 2 Jul 2012 11:47:27 -0700 Subject: [PATCH] Fixing issue where toasts were getting queued. (Bug 6572269) Change-Id: Iceb27c4c5a4168beb5a5ae37a0c597e1940bff04 --- src/com/android/launcher2/AppsCustomizePagedView.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index d55260c86b..80fc62fce6 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -300,6 +300,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen PendingAddWidgetInfo mCreateWidgetInfo = null; private boolean mDraggingWidget = false; + private Toast mWidgetInstructionToast; + // Deferral of loading widget previews during launcher transitions private boolean mInTransition; private ArrayList mDeferredSyncWidgetPageItems = @@ -577,8 +579,12 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } else if (v instanceof PagedViewWidget) { // Let the user know that they have to long press to add a widget - Toast.makeText(getContext(), R.string.long_press_widget_to_add, - Toast.LENGTH_SHORT).show(); + if (mWidgetInstructionToast != null) { + mWidgetInstructionToast.cancel(); + } + mWidgetInstructionToast = Toast.makeText(getContext(),R.string.long_press_widget_to_add, + Toast.LENGTH_SHORT); + mWidgetInstructionToast.show(); // Create a little animation to show that the widget can move float offsetY = getResources().getDimensionPixelSize(R.dimen.dragViewOffsetY);