diff options
author | Adam Cohen <adamcohen@google.com> | 2011-07-17 12:56:20 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-17 12:56:20 -0700 |
commit | ff35bf81a24812cb7dc33bbaddcfed1e44d418d2 (patch) | |
tree | 34ecfceaa8af67111ef9a478a6be13c38a2e668f /src/com/android/launcher2/DragLayer.java | |
parent | 7494c5616630a11615f5ae8f05c02878eb866569 (diff) | |
parent | b7e1618c627c6471c565f4f599228648d9e70a10 (diff) | |
download | android_packages_apps_Trebuchet-ff35bf81a24812cb7dc33bbaddcfed1e44d418d2.tar.gz android_packages_apps_Trebuchet-ff35bf81a24812cb7dc33bbaddcfed1e44d418d2.tar.bz2 android_packages_apps_Trebuchet-ff35bf81a24812cb7dc33bbaddcfed1e44d418d2.zip |
Merge "Improving adding widgets animations"
Diffstat (limited to 'src/com/android/launcher2/DragLayer.java')
-rw-r--r-- | src/com/android/launcher2/DragLayer.java | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java index 37abe5a7c..9997c2957 100644 --- a/src/com/android/launcher2/DragLayer.java +++ b/src/com/android/launcher2/DragLayer.java @@ -178,7 +178,7 @@ public class DragLayer extends FrameLayout { return scale; } - private float getDescendantCoordRelativeToSelf(View descendant, int[] coord) { + public float getDescendantCoordRelativeToSelf(View descendant, int[] coord) { float scale = 1.0f; float[] pt = {coord[0], coord[1]}; descendant.getMatrix().mapPoints(pt); @@ -319,6 +319,17 @@ public class DragLayer extends FrameLayout { animateViewIntoPosition(dragView, child, null); } + public void animateViewIntoPosition(DragView dragView, final int[] pos, float scale, + Runnable onFinishRunnable) { + Rect r = new Rect(); + getViewRectRelativeToSelf(dragView, r); + final int fromX = r.left; + final int fromY = r.top; + + animateViewIntoPosition(dragView, fromX, fromY, pos[0], pos[1], scale, + onFinishRunnable, true); + } + public void animateViewIntoPosition(DragView dragView, final View child, final Runnable onFinishAnimationRunnable) { ((CellLayoutChildren) child.getParent()).measureChild(child); @@ -373,18 +384,6 @@ public class DragLayer extends FrameLayout { animateViewIntoPosition(dragView, fromX, fromY, toX, toY, scale, onCompleteRunnable, true); } - /* Just fade out in place */ - public void animateViewOut(DragView dragView, Runnable onFinishAnimationRunnable) { - Rect r = new Rect(); - getViewRectRelativeToSelf(dragView, r); - final int fromX = r.left; - final int fromY = r.top; - final int toX = fromX; - final int toY = fromY; - animateViewIntoPosition(dragView, fromX, fromY, toX, toY, 1.0f, onFinishAnimationRunnable, - true); - } - private void animateViewIntoPosition(final View view, final int fromX, final int fromY, final int toX, final int toY, float finalScale, Runnable onCompleteRunnable, boolean fadeOut) { @@ -394,6 +393,24 @@ public class DragLayer extends FrameLayout { animateView(view, from, to, 1f, finalScale, -1, null, null, onCompleteRunnable, true); } + /** + * This method animates a view at the end of a drag and drop animation. + * + * @param view The view to be animated. This view is drawn directly into DragLayer, and so + * doesn't need to be a child of DragLayer. + * @param from The initial location of the view. Only the left and top parameters are used. + * @param to The final location of the view. Only the left and top parameters are used. This + * location doesn't account for scaling, and so should be centered about the desired + * final location (including scaling). + * @param finalAlpha The final alpha of the view, in case we want it to fade as it animates. + * @param finalScale The final scale of the view. The view is scaled about its center. + * @param duration The duration of the animation. + * @param motionInterpolator The interpolator to use for the location of the view. + * @param alphaInterpolator The interpolator to use for the alpha of the view. + * @param onCompleteRunnable Optional runnable to run on animation completion. + * @param fadeOut Whether or not to fade out the view once the animation completes. If true, + * the runnable will execute after the view is faded out. + */ public void animateView(final View view, final Rect from, final Rect to, final float finalAlpha, final float finalScale, int duration, final Interpolator motionInterpolator, final Interpolator alphaInterpolator, final Runnable onCompleteRunnable, |