From 7bccb42f88cbbaf8cf180a876e8c5d5e306ce62a Mon Sep 17 00:00:00 2001 From: Patrick Dubroy Date: Thu, 20 Jan 2011 14:50:55 -0800 Subject: [PATCH] Fix 3373059: Crash when drag cancelled in spring-loaded state --- src/com/android/launcher2/AllAppsPagedView.java | 2 +- src/com/android/launcher2/CustomizePagedView.java | 2 +- src/com/android/launcher2/Workspace.java | 10 +++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher2/AllAppsPagedView.java b/src/com/android/launcher2/AllAppsPagedView.java index 64da1b4ef0..fe7312d69e 100644 --- a/src/com/android/launcher2/AllAppsPagedView.java +++ b/src/com/android/launcher2/AllAppsPagedView.java @@ -288,7 +288,7 @@ public class AllAppsPagedView extends PagedViewWithDraggableItems implements All endChoiceMode(); } tearDownDragMode(); - mLauncher.getWorkspace().onDragStopped(); + mLauncher.getWorkspace().onDragStopped(success); mLauncher.unlockScreenOrientation(); } diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java index d9a6612734..c74e5f42e8 100644 --- a/src/com/android/launcher2/CustomizePagedView.java +++ b/src/com/android/launcher2/CustomizePagedView.java @@ -327,7 +327,7 @@ public class CustomizePagedView extends PagedViewWithDraggableItems @Override public void onDropCompleted(View target, boolean success) { resetCheckedGrandchildren(); - mLauncher.getWorkspace().onDragStopped(); + mLauncher.getWorkspace().onDragStopped(success); mLauncher.unlockScreenOrientation(); } diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 56055d9bc8..b9a2b62348 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -1458,6 +1458,7 @@ public class Workspace extends SmoothPagedView cl.setIsDefaultDropTarget(i == mCurrentPage); case BOTTOM_HIDDEN: case BOTTOM_VISIBLE: + case SPRING_LOADED: if (!isDragHappening) { // even if a drag isn't happening, we don't want to show a screen as // accepting drops if it doesn't have at least one free cell @@ -1468,8 +1469,7 @@ public class Workspace extends SmoothPagedView cl.setAcceptsDrops(cl.findCellForSpan(null, spanX, spanY)); break; default: - throw new RuntimeException( - "updateWhichPagesAcceptDropsHelper passed an unhandled ShrinkState"); + throw new RuntimeException("Unhandled ShrinkState " + state); } } } @@ -1499,7 +1499,11 @@ public class Workspace extends SmoothPagedView // we call this method whenever a drag and drop in Launcher finishes, even if Workspace was // never dragged over - public void onDragStopped() { + public void onDragStopped(boolean success) { + // In the success case, DragController has already called onDragExit() + if (!success) { + doDragExit(); + } mIsDragInProcess = false; updateWhichPagesAcceptDrops(mShrinkState); }