summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/dragndrop/DragController.java
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2016-10-05 09:05:42 -0700
committerTony Wickham <twickham@google.com>2016-11-02 15:07:57 -0700
commitea62fe0be19c54f8fbb434c6334418b96626f70d (patch)
treef9d9c9794f37f8f60e9eb8c1f6ee79e4bb53a005 /src/com/android/launcher3/dragndrop/DragController.java
parentdf3bc52ca9c4271398d35b17cf550ca9099b8249 (diff)
downloadandroid_packages_apps_Trebuchet-ea62fe0be19c54f8fbb434c6334418b96626f70d.tar.gz
android_packages_apps_Trebuchet-ea62fe0be19c54f8fbb434c6334418b96626f70d.tar.bz2
android_packages_apps_Trebuchet-ea62fe0be19c54f8fbb434c6334418b96626f70d.zip
Animate icons back to where they were picked up.
We do this for pre-dragged icons instead of calling onDrop(). - Removes need for special logic in onDrop() to check if mIsInPreDrag - Dropping from pre-drag in all apps also animates instead of jumping We also do this when dropping an icon while still transitioning to spring-loaded mode, to avoid having a janky jump at the end - Bug: 27135377 Change-Id: I4548c3e2fef3423d1ba36057fb53807b1b4ad0fc
Diffstat (limited to 'src/com/android/launcher3/dragndrop/DragController.java')
-rw-r--r--src/com/android/launcher3/dragndrop/DragController.java29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java
index e11bfc682..67ef5fc3c 100644
--- a/src/com/android/launcher3/dragndrop/DragController.java
+++ b/src/com/android/launcher3/dragndrop/DragController.java
@@ -295,10 +295,6 @@ public class DragController implements DragDriver.EventListener, TouchController
mIsInPreDrag = false;
}
- public boolean isInPreDrag() {
- return mIsInPreDrag;
- }
-
/**
* Call this from a drag source view like this:
*
@@ -361,6 +357,8 @@ public class DragController implements DragDriver.EventListener, TouchController
isDeferred = mDragObject.deferDragViewCleanupPostAnimation;
if (!isDeferred) {
mDragObject.dragView.remove();
+ } else if (mIsInPreDrag) {
+ animateDragViewToOriginalPosition(null, null, -1);
}
mDragObject.dragView = null;
}
@@ -374,6 +372,22 @@ public class DragController implements DragDriver.EventListener, TouchController
releaseVelocityTracker();
}
+ public void animateDragViewToOriginalPosition(final Runnable onComplete,
+ final View originalIcon, int duration) {
+ Runnable onCompleteRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if (originalIcon != null) {
+ originalIcon.setVisibility(View.VISIBLE);
+ }
+ if (onComplete != null) {
+ onComplete.run();
+ }
+ }
+ };
+ mDragObject.dragView.animateTo(mMotionDownX, mMotionDownY, onCompleteRunnable, duration);
+ }
+
private void callOnDragEnd() {
if (mIsInPreDrag && mOptions.preDragCondition != null) {
mOptions.preDragCondition.onPreDragEnd(false /* dragStarted*/);
@@ -738,7 +752,7 @@ public class DragController implements DragDriver.EventListener, TouchController
if (dropTarget.acceptDrop(mDragObject)) {
if (flingVel != null) {
dropTarget.onFlingToDelete(mDragObject, flingVel);
- } else {
+ } else if (!mIsInPreDrag) {
dropTarget.onDrop(mDragObject);
}
accepted = true;
@@ -749,11 +763,6 @@ public class DragController implements DragDriver.EventListener, TouchController
if (!mIsInPreDrag) {
mDragObject.dragSource.onDropCompleted(
dropTargetAsView, mDragObject, flingVel != null, accepted);
- } else {
- // Only defer the drag view cleanup if the drag source handles the drop.
- if (!(mDragObject.dragSource instanceof DropTarget)) {
- mDragObject.deferDragViewCleanupPostAnimation = false;
- }
}
}