summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/DeleteDropTarget.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2012-01-23 17:28:51 -0800
committerAdam Cohen <adamcohen@google.com>2012-02-13 13:30:32 -0800
commited66b2bac7447febe2e405b4ce725cae4f6b5988 (patch)
tree8c3e31c514a976a9d1e7045206e21da12c031559 /src/com/android/launcher2/DeleteDropTarget.java
parent933cc5061100f22c22d66d280b6fdd07634f45a6 (diff)
downloadandroid_packages_apps_Trebuchet-ed66b2bac7447febe2e405b4ce725cae4f6b5988.tar.gz
android_packages_apps_Trebuchet-ed66b2bac7447febe2e405b4ce725cae4f6b5988.tar.bz2
android_packages_apps_Trebuchet-ed66b2bac7447febe2e405b4ce725cae4f6b5988.zip
Improving widget transitions:
-> When a widget has no configuration activity, we bind and inflate it when the user picks it up. This allows us to smoothly transition between it's preview and some actual state of the widget when it is dropped. -> When a widget has a configuration activity, we delay the above process until the configuration activity has been run at which time we transition between the preview and the actual widget. Change-Id: I5265cd98400d70e5e75c3dcd21e322ed0b352d7b
Diffstat (limited to 'src/com/android/launcher2/DeleteDropTarget.java')
-rw-r--r--src/com/android/launcher2/DeleteDropTarget.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/com/android/launcher2/DeleteDropTarget.java b/src/com/android/launcher2/DeleteDropTarget.java
index 3b82f9e94..a6b2b5c8b 100644
--- a/src/com/android/launcher2/DeleteDropTarget.java
+++ b/src/com/android/launcher2/DeleteDropTarget.java
@@ -165,23 +165,30 @@ public class DeleteDropTarget extends ButtonDropTarget {
}
}
- private void animateToTrashAndCompleteDrop(final DragObject d) {
+ Rect getDeleteRect(int deleteItemWidth, int deleteItemHeight) {
DragLayer dragLayer = mLauncher.getDragLayer();
- Rect from = new Rect();
+
Rect to = new Rect();
- dragLayer.getViewRectRelativeToSelf(d.dragView, from);
dragLayer.getViewRectRelativeToSelf(this, to);
-
int width = mCurrentDrawable.getIntrinsicWidth();
int height = mCurrentDrawable.getIntrinsicHeight();
to.set(to.left + getPaddingLeft(), to.top + getPaddingTop(),
to.left + getPaddingLeft() + width, to.bottom);
// Center the destination rect about the trash icon
- int xOffset = (int) -(d.dragView.getMeasuredWidth() - width) / 2;
- int yOffset = (int) -(d.dragView.getMeasuredHeight() - height) / 2;
+ int xOffset = (int) -(deleteItemWidth - width) / 2;
+ int yOffset = (int) -(deleteItemHeight - height) / 2;
to.offset(xOffset, yOffset);
+ return to;
+ }
+
+ private void animateToTrashAndCompleteDrop(final DragObject d) {
+ DragLayer dragLayer = mLauncher.getDragLayer();
+ Rect from = new Rect();
+ dragLayer.getViewRectRelativeToSelf(d.dragView, from);
+ Rect to = getDeleteRect(d.dragView.getMeasuredWidth(), d.dragView.getMeasuredHeight());
+
mSearchDropTargetBar.deferOnDragEnd();
Runnable onAnimationEndRunnable = new Runnable() {
@Override
@@ -191,9 +198,10 @@ public class DeleteDropTarget extends ButtonDropTarget {
completeDrop(d);
}
};
- dragLayer.animateView(d.dragView, from, to, 0.1f, 0.1f,
+ dragLayer.animateView(d.dragView, from, to, 0.1f, 1, 1, 0.1f, 0.1f,
DELETE_ANIMATION_DURATION, new DecelerateInterpolator(2),
- new DecelerateInterpolator(1.5f), onAnimationEndRunnable, false, null);
+ new DecelerateInterpolator(1.5f), onAnimationEndRunnable,
+ DragLayer.ANIMATION_END_DISAPPEAR, null);
}
private void completeDrop(DragObject d) {