summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorPatrick Dubroy <dubroy@google.com>2010-11-01 15:41:33 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-11-01 15:41:33 -0700
commit30110328a249a049673266bfce39ca9dcf650af9 (patch)
tree4fcbda2b9ce7647ee6ff8abfabbca8bbb6d71e10 /src/com
parent9e48238c39e6048550ac3e63dac88843ab402935 (diff)
parent8ae3a62e2e48dfb8f860c8b6e2c7e72b9595d7aa (diff)
downloadandroid_packages_apps_Trebuchet-30110328a249a049673266bfce39ca9dcf650af9.tar.gz
android_packages_apps_Trebuchet-30110328a249a049673266bfce39ca9dcf650af9.tar.bz2
android_packages_apps_Trebuchet-30110328a249a049673266bfce39ca9dcf650af9.zip
Merge "Add snap-back animation when dropping an item on a full page."
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher2/Workspace.java37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 2ddd04482..c4ca9e1e1 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -164,6 +164,9 @@ public class Workspace extends SmoothPagedView
// Paint used to draw external drop outline
private final Paint mExternalDragOutlinePaint = new Paint();
+ /** Used to trigger an animation as soon as the workspace stops scrolling. */
+ private Animator mAnimOnPageEndMoving = null;
+
/**
* Used to inflate the Workspace from XML.
*
@@ -462,6 +465,12 @@ public class Workspace extends SmoothPagedView
if (!mDragController.dragging()) {
hideOutlines();
}
+ // Check for an animation that's waiting to be started
+ if (mAnimOnPageEndMoving != null) {
+ mAnimOnPageEndMoving.start();
+ mAnimOnPageEndMoving = null;
+ }
+
mPageMoving = false;
}
@@ -594,6 +603,8 @@ public class Workspace extends SmoothPagedView
super.dispatchDraw(canvas);
if (mDropView != null) {
+ // We are animating an item that was just dropped on the home screen.
+ // Render its View in the current animation position.
canvas.save(Canvas.MATRIX_SAVE_FLAG);
final int xPos = mDropViewPos[0] - mDropView.getScrollX();
final int yPos = mDropViewPos[1] - mDropView.getScrollY();
@@ -1143,8 +1154,6 @@ public class Workspace extends SmoothPagedView
final CellLayout parent = (CellLayout) view.getParent();
final CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams();
- mDropView = view;
-
// Convert the animation params to be relative to the Workspace, not the CellLayout
final int fromX = lp.oldX + parent.getLeft();
final int fromY = lp.oldY + parent.getTop();
@@ -1156,18 +1165,21 @@ public class Workspace extends SmoothPagedView
final float dist = (float) Math.sqrt(dx*dx + dy*dy);
final Resources res = getResources();
final float maxDist = (float) res.getInteger(R.integer.config_dropAnimMaxDist);
- final int duration = (int) (res.getInteger(R.integer.config_dropAnimMaxDuration)
- * mQuintEaseOutInterpolator.getInterpolation(dist / maxDist));
+ int duration = res.getInteger(R.integer.config_dropAnimMaxDuration);
+ if (dist < maxDist) {
+ duration *= mQuintEaseOutInterpolator.getInterpolation(dist / maxDist);
+ }
// Lazy initialize the animation
if (mDropAnim == null) {
mDropAnim = new ValueAnimator();
mDropAnim.setInterpolator(mQuintEaseOutInterpolator);
- // Make the view invisible during the animation; we'll render it manually.
+ // The view is invisible during the animation; we render it manually.
mDropAnim.addListener(new AnimatorListenerAdapter() {
public void onAnimationStart(Animator animation) {
- mDropView.setVisibility(View.INVISIBLE);
+ // Set this here so that we don't render it until the animation begins
+ mDropView = view;
}
public void onAnimationEnd(Animator animation) {
@@ -1180,6 +1192,7 @@ public class Workspace extends SmoothPagedView
} else {
mDropAnim.end(); // Make sure it's not already running
}
+
mDropAnim.setDuration(duration);
mDropAnim.setFloatValues(0.0f, 1.0f);
mDropAnim.removeAllUpdateListeners();
@@ -1196,7 +1209,15 @@ public class Workspace extends SmoothPagedView
mDropViewPos[0] + view.getWidth(), mDropViewPos[1] + view.getHeight());
}
});
- mDropAnim.start();
+
+
+ view.setVisibility(View.INVISIBLE);
+
+ if (!mScroller.isFinished()) {
+ mAnimOnPageEndMoving = mDropAnim;
+ } else {
+ mDropAnim.start();
+ }
}
/**
@@ -1253,7 +1274,7 @@ public class Workspace extends SmoothPagedView
mTargetCell);
if (mTargetCell == null) {
- mLauncher.showOutOfSpaceMessage();
+ snapToPage(mDragInfo.screen);
} else {
int screen = indexOfChild(mDragTargetLayout);
if (screen != mDragInfo.screen) {