summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/CellLayout.java
diff options
context:
space:
mode:
authorBrandon Keely <lbk@google.com>2012-05-08 16:28:49 -0700
committerBrandon Keely <lbk@google.com>2012-05-08 16:28:49 -0700
commit50e6e565bcf1f51023c2a14d31b17c8a550aac84 (patch)
treebba3233d2691246175d49ef03843e5e769c6d74d /src/com/android/launcher2/CellLayout.java
parentbec653ea44429bbe85fb334a8c8ba6520e3fa209 (diff)
downloadandroid_packages_apps_Trebuchet-50e6e565bcf1f51023c2a14d31b17c8a550aac84.tar.gz
android_packages_apps_Trebuchet-50e6e565bcf1f51023c2a14d31b17c8a550aac84.tar.bz2
android_packages_apps_Trebuchet-50e6e565bcf1f51023c2a14d31b17c8a550aac84.zip
Adjusting animations for home screen widget reordering.
Change-Id: Ic019b0db8456159d9577acb9a03e24f0d669869b
Diffstat (limited to 'src/com/android/launcher2/CellLayout.java')
-rw-r--r--src/com/android/launcher2/CellLayout.java31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index ba20a76ba..ee759a217 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -17,6 +17,8 @@
package com.android.launcher2;
import android.animation.Animator;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
import android.animation.AnimatorListenerAdapter;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
@@ -149,7 +151,7 @@ public class CellLayout extends ViewGroup {
static final int LANDSCAPE = 0;
static final int PORTRAIT = 1;
- private static final float REORDER_HINT_MAGNITUDE = 0.27f;
+ private static final float REORDER_HINT_MAGNITUDE = 0.10f;
private static final int REORDER_ANIMATION_DURATION = 150;
private float mReorderHintAnimationMagnitude;
@@ -1962,7 +1964,7 @@ public class CellLayout extends ViewGroup {
View child;
float deltaX;
float deltaY;
- private static final int DURATION = 140;
+ private static final int DURATION = 300;
private int repeatCount;
private boolean cancelOnCycleComplete = false;
ValueAnimator va;
@@ -1991,6 +1993,8 @@ public class CellLayout extends ViewGroup {
deltaY = (int) (Math.sin(angle) * mReorderHintAnimationMagnitude);
}
}
+ child.setPivotY(child.getMeasuredHeight() * 0.5f);
+ child.setPivotX(child.getMeasuredWidth() * 0.5f);
this.child = child;
}
@@ -2006,7 +2010,7 @@ public class CellLayout extends ViewGroup {
va = ValueAnimator.ofFloat(0f, 1f);
va.setRepeatMode(ValueAnimator.REVERSE);
va.setRepeatCount(ValueAnimator.INFINITE);
- va.setDuration(DURATION);
+ va.setDuration((int) (DURATION * (1.0f + Math.random()*.08f)));
va.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
@@ -2015,6 +2019,10 @@ public class CellLayout extends ViewGroup {
float y = r * deltaY;
child.setTranslationX(x);
child.setTranslationY(y);
+ float sf = 4.0f / child.getWidth();
+ float s = 1.0f - r * sf;
+ child.setScaleX(s);
+ child.setScaleY(s);
}
});
va.addListener(new AnimatorListenerAdapter() {
@@ -2035,6 +2043,21 @@ public class CellLayout extends ViewGroup {
private void completeAnimation() {
cancelOnCycleComplete = true;
}
+ private void completeAnimationImmediately() {
+ va.cancel();
+
+ AnimatorSet s = new AnimatorSet();
+ s.playTogether(
+ ObjectAnimator.ofFloat(child, "scaleX", 1f),
+ ObjectAnimator.ofFloat(child, "scaleY", 1f),
+ ObjectAnimator.ofFloat(child, "translationX", 0f),
+ ObjectAnimator.ofFloat(child, "translationX", 0f)
+ );
+ s.setDuration(REORDER_ANIMATION_DURATION);
+ s.setInterpolator(new android.view.animation.DecelerateInterpolator(1.5f));
+ s.start();
+ }
+
// Returns the time required to complete the current oscillating animation
private int completionTime() {
@@ -2048,7 +2071,7 @@ public class CellLayout extends ViewGroup {
private void completeAndClearReorderHintAnimations() {
for (ReorderHintAnimation a: mShakeAnimators.values()) {
- a.completeAnimation();
+ a.completeAnimationImmediately();
}
mShakeAnimators.clear();
}