diff options
author | Adam Cohen <adamcohen@google.com> | 2014-05-08 17:27:56 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2014-05-09 15:05:53 -0700 |
commit | 689ff16ea27fb7c22c247aaf4f42ffe42fede253 (patch) | |
tree | 543505e8ed9d537c43fd7a20957d6d0ed6ed186b /src/com/android/launcher3/Workspace.java | |
parent | 1317e2dd4a2fb097d1e54759536d515fdeca2c3e (diff) | |
download | android_packages_apps_Trebuchet-689ff16ea27fb7c22c247aaf4f42ffe42fede253.tar.gz android_packages_apps_Trebuchet-689ff16ea27fb7c22c247aaf4f42ffe42fede253.tar.bz2 android_packages_apps_Trebuchet-689ff16ea27fb7c22c247aaf4f42ffe42fede253.zip |
Cleanup pattern for removing the extra empty screen after drag operations
-> Fixes a couple bugs: issue 12179908, issue 12372657, issue 13287732
Change-Id: I24b5abe8e432ea331eeb77407120a8cec28f6376
Diffstat (limited to 'src/com/android/launcher3/Workspace.java')
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 9bf2c2343..b3712cde5 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -135,6 +135,7 @@ public class Workspace extends SmoothPagedView private ArrayList<Long> mScreenOrder = new ArrayList<Long>(); private Runnable mRemoveEmptyScreenRunnable; + private boolean mDeferRemoveExtraEmptyScreen = false; /** * CellInfo for the cell that is currently being dragged @@ -397,13 +398,25 @@ public class Workspace extends SmoothPagedView @Override public void run() { if (mIsDragOccuring) { + mDeferRemoveExtraEmptyScreen = false; addExtraEmptyScreenOnDrag(); } } }); } + + public void deferRemoveExtraEmptyScreen() { + mDeferRemoveExtraEmptyScreen = true; + } + public void onDragEnd() { + System.out.println("onDrag end workspace"); + + if (!mDeferRemoveExtraEmptyScreen) { + removeExtraEmptyScreen(true, mDragSourceInternal != null); + } + mIsDragOccuring = false; updateChildrenLayersEnabled(false); mLauncher.unlockScreenOrientation(false); @@ -726,11 +739,11 @@ public class Workspace extends SmoothPagedView } } - public void removeExtraEmptyScreen(final boolean animate, final Runnable onComplete) { - removeExtraEmptyScreen(animate, onComplete, 0, false); + public void removeExtraEmptyScreen(final boolean animate, boolean stripEmptyScreens) { + removeExtraEmptyScreenDelayed(animate, null, 0, stripEmptyScreens); } - public void removeExtraEmptyScreen(final boolean animate, final Runnable onComplete, + public void removeExtraEmptyScreenDelayed(final boolean animate, final Runnable onComplete, final int delay, final boolean stripEmptyScreens) { // Log to disk Launcher.addDumpLog(TAG, "11683562 - removeExtraEmptyScreen()", true); @@ -744,9 +757,8 @@ public class Workspace extends SmoothPagedView postDelayed(new Runnable() { @Override public void run() { - removeExtraEmptyScreen(animate, onComplete, 0, stripEmptyScreens); + removeExtraEmptyScreenDelayed(animate, onComplete, 0, stripEmptyScreens); } - }, delay); return; } @@ -3056,13 +3068,11 @@ public class Workspace extends SmoothPagedView // cell also contains a shortcut, then create a folder with the two shortcuts. if (!mInScrollArea && createUserFolderIfNecessary(cell, container, dropTargetLayout, mTargetCell, distance, false, d.dragView, null)) { - removeExtraEmptyScreen(true, null, 0, true); return; } if (addToExistingFolderIfNecessary(cell, dropTargetLayout, mTargetCell, distance, d, false)) { - removeExtraEmptyScreen(true, null, 0, true); return; } @@ -3168,7 +3178,6 @@ public class Workspace extends SmoothPagedView if (finalResizeRunnable != null) { finalResizeRunnable.run(); } - removeExtraEmptyScreen(true, null, 0, true); } }; mAnimatingViewIntoPlace = true; @@ -3822,13 +3831,8 @@ public class Workspace extends SmoothPagedView final Runnable exitSpringLoadedRunnable = new Runnable() { @Override public void run() { - removeExtraEmptyScreen(false, new Runnable() { - @Override - public void run() { - mLauncher.exitSpringLoadedDragModeDelayed(true, - Launcher.EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT, null); - } - }); + mLauncher.exitSpringLoadedDragModeDelayed(true, + Launcher.EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT, null); } }; @@ -3890,6 +3894,11 @@ public class Workspace extends SmoothPagedView Runnable onAnimationCompleteRunnable = new Runnable() { @Override public void run() { + // Normally removeExtraEmptyScreen is called in Workspace#onDragEnd, but when + // adding an item that may not be dropped right away (due to a config activity) + // we defer the removal until the activity returns. + deferRemoveExtraEmptyScreen(); + // When dragging and dropping from customization tray, we deal with creating // widgets/shortcuts/folders in a slightly different way switch (pendingInfo.itemType) { @@ -4190,10 +4199,6 @@ public class Workspace extends SmoothPagedView if (mDragInfo.cell instanceof DropTarget) { mDragController.removeDropTarget((DropTarget) mDragInfo.cell); } - // If we move the item to anything not on the Workspace, check if any empty - // screens need to be removed. If we dropped back on the workspace, this will - // be done post drop animation. - removeExtraEmptyScreen(true, null, 0, true); } } else if (mDragInfo != null) { CellLayout cellLayout; |