summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorChet Haase <chet@google.com>2010-10-14 07:02:04 -0700
committerChet Haase <chet@google.com>2010-10-14 10:51:21 -0700
commit472b281d5cb4f5660df981a6c912266b9f5703fe (patch)
treeec2393d2d472bda0893e861e19722ab9f7cc3c27 /src/com
parent564976a46ef02d665aa0e455ad7867746a0b5325 (diff)
downloadandroid_packages_apps_Trebuchet-472b281d5cb4f5660df981a6c912266b9f5703fe.tar.gz
android_packages_apps_Trebuchet-472b281d5cb4f5660df981a6c912266b9f5703fe.tar.bz2
android_packages_apps_Trebuchet-472b281d5cb4f5660df981a6c912266b9f5703fe.zip
Updating code to use new non-generified animator APIs
Change-Id: Ie1928a22f774b226d90fa0918f61dba35d183dd6
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher2/AllAppsTabbed.java8
-rw-r--r--src/com/android/launcher2/CellLayout.java25
-rw-r--r--src/com/android/launcher2/InterruptibleInOutAnimator.java36
-rw-r--r--src/com/android/launcher2/Launcher.java34
-rw-r--r--src/com/android/launcher2/Workspace.java50
5 files changed, 84 insertions, 69 deletions
diff --git a/src/com/android/launcher2/AllAppsTabbed.java b/src/com/android/launcher2/AllAppsTabbed.java
index aff8ddd20..cc6a14907 100644
--- a/src/com/android/launcher2/AllAppsTabbed.java
+++ b/src/com/android/launcher2/AllAppsTabbed.java
@@ -103,7 +103,8 @@ public class AllAppsTabbed extends TabHost implements AllAppsView {
// animate the changing of the tab content by fading pages in and out
final int duration = 150;
final float alpha = mAllApps.getAlpha();
- ValueAnimator alphaAnim = new ObjectAnimator(duration, mAllApps, "alpha", alpha, 0.0f);
+ ValueAnimator alphaAnim = ObjectAnimator.ofFloat(mAllApps, "alpha", alpha, 0.0f).
+ setDuration(duration);
alphaAnim.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
String tag = getCurrentTabTag();
@@ -118,9 +119,8 @@ public class AllAppsTabbed extends TabHost implements AllAppsView {
}
final float alpha = mAllApps.getAlpha();
- ValueAnimator alphaAnim =
- new ObjectAnimator(duration, mAllApps, "alpha", alpha, 1.0f);
- alphaAnim.start();
+ ObjectAnimator.ofFloat(mAllApps, "alpha", alpha, 1.0f).
+ setDuration(duration).start();
}
});
alphaAnim.start();
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 3c6a8aaed..c7c850b65 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -94,7 +94,7 @@ public class CellLayout extends ViewGroup implements Dimmable {
// These arrays are used to implement the drag visualization on x-large screens.
// They are used as circular arrays, indexed by mDragOutlineCurrent.
private Point[] mDragOutlines = new Point[8];
- private int[] mDragOutlineAlphas = new int[mDragOutlines.length];
+ private float[] mDragOutlineAlphas = new float[mDragOutlines.length];
private InterruptibleInOutAnimator[] mDragOutlineAnims =
new InterruptibleInOutAnimator[mDragOutlines.length];
@@ -175,13 +175,13 @@ public class CellLayout extends ViewGroup implements Dimmable {
// Set up the animation for fading the crosshairs in and out
int animDuration = res.getInteger(R.integer.config_crosshairsFadeInTime);
mCrosshairsAnimator = new InterruptibleInOutAnimator(animDuration, 0.0f, 1.0f);
- mCrosshairsAnimator.addUpdateListener(new AnimatorUpdateListener() {
+ mCrosshairsAnimator.getAnimator().addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
mCrosshairsVisibility = ((Float) animation.getAnimatedValue()).floatValue();
CellLayout.this.invalidate();
}
});
- mCrosshairsAnimator.setInterpolator(interp);
+ mCrosshairsAnimator.getAnimator().setInterpolator(interp);
for (int i = 0; i < mDragOutlines.length; i++) {
mDragOutlines[i] = new Point(-1, -1);
@@ -192,8 +192,8 @@ public class CellLayout extends ViewGroup implements Dimmable {
// behind the drag path.
// Set up all the animations that are used to implement this fading.
final int duration = res.getInteger(R.integer.config_dragOutlineFadeTime);
- final int fromAlphaValue = 0;
- final int toAlphaValue = res.getInteger(R.integer.config_dragOutlineMaxAlpha);
+ final float fromAlphaValue = 0;
+ final float toAlphaValue = (float)res.getInteger(R.integer.config_dragOutlineMaxAlpha);
for (int i = 0; i < mDragOutlineAlphas.length; i++) {
mDragOutlineAlphas[i] = fromAlphaValue;
@@ -202,10 +202,9 @@ public class CellLayout extends ViewGroup implements Dimmable {
for (int i = 0; i < mDragOutlineAnims.length; i++) {
final InterruptibleInOutAnimator anim =
new InterruptibleInOutAnimator(duration, fromAlphaValue, toAlphaValue);
- anim.setInterpolator(interp);
-
+ anim.getAnimator().setInterpolator(interp);
final int thisIndex = i;
- anim.addUpdateListener(new AnimatorUpdateListener() {
+ anim.getAnimator().addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
final Bitmap outline = (Bitmap)anim.getTag();
@@ -221,7 +220,7 @@ public class CellLayout extends ViewGroup implements Dimmable {
// Try to prevent it from continuing to run
animation.cancel();
} else {
- mDragOutlineAlphas[thisIndex] = (Integer) animation.getAnimatedValue();
+ mDragOutlineAlphas[thisIndex] = (Float) animation.getAnimatedValue();
final int left = mDragOutlines[thisIndex].x;
final int top = mDragOutlines[thisIndex].y;
CellLayout.this.invalidate(left, top,
@@ -231,9 +230,9 @@ public class CellLayout extends ViewGroup implements Dimmable {
});
// The animation holds a reference to the drag outline bitmap as long is it's
// running. This way the bitmap can be GCed when the animations are complete.
- anim.addListener(new AnimatorListenerAdapter() {
+ anim.getAnimator().addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
- if ((Integer) anim.getAnimatedValue() == 0) {
+ if ((Float) ((ValueAnimator) animation).getAnimatedValue() == 0f) {
anim.setTag(null);
}
}
@@ -311,11 +310,11 @@ public class CellLayout extends ViewGroup implements Dimmable {
final Paint paint = new Paint();
for (int i = 0; i < mDragOutlines.length; i++) {
- final int alpha = mDragOutlineAlphas[i];
+ final float alpha = mDragOutlineAlphas[i];
if (alpha > 0) {
final Point p = mDragOutlines[i];
final Bitmap b = (Bitmap) mDragOutlineAnims[i].getTag();
- paint.setAlpha(alpha);
+ paint.setAlpha((int)(alpha + .5f));
canvas.drawBitmap(b, p.x, p.y, paint);
}
}
diff --git a/src/com/android/launcher2/InterruptibleInOutAnimator.java b/src/com/android/launcher2/InterruptibleInOutAnimator.java
index 0b2f34561..bed7e6b28 100644
--- a/src/com/android/launcher2/InterruptibleInOutAnimator.java
+++ b/src/com/android/launcher2/InterruptibleInOutAnimator.java
@@ -18,6 +18,7 @@ package com.android.launcher2;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
+import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.util.Log;
@@ -28,10 +29,11 @@ import android.util.Log;
* be exactly reversed. Using this class, both the 'in' and the 'out' animation use the
* interpolator in the same direction.
*/
-public class InterruptibleInOutAnimator extends ValueAnimator {
+public class InterruptibleInOutAnimator {
private long mOriginalDuration;
- private Object mOriginalFromValue;
- private Object mOriginalToValue;
+ private float mOriginalFromValue;
+ private float mOriginalToValue;
+ private ValueAnimator mAnimator;
private boolean mFirstRun = true;
@@ -41,41 +43,41 @@ public class InterruptibleInOutAnimator extends ValueAnimator {
private static final int IN = 1;
private static final int OUT = 2;
+
private int mDirection = STOPPED;
- public InterruptibleInOutAnimator(long duration, Object fromValue, Object toValue) {
- super(duration, fromValue, toValue);
+ public InterruptibleInOutAnimator(long duration, float fromValue, float toValue) {
+ mAnimator = ValueAnimator.ofFloat(fromValue, toValue).setDuration(duration);
mOriginalDuration = duration;
mOriginalFromValue = fromValue;
mOriginalToValue = toValue;
}
private void animate(int direction) {
- final long currentPlayTime = getCurrentPlayTime();
- final Object toValue = (direction == IN) ? mOriginalToValue : mOriginalFromValue;
- final Object startValue = mFirstRun ? mOriginalFromValue : getAnimatedValue();
+ final long currentPlayTime = mAnimator.getCurrentPlayTime();
+ final float toValue = (direction == IN) ? mOriginalToValue : mOriginalFromValue;
+ final float startValue = mFirstRun ? mOriginalFromValue :
+ ((Float) mAnimator.getAnimatedValue()).floatValue();
// Make sure it's stopped before we modify any values
cancel();
if (startValue != toValue) {
mDirection = direction;
- setDuration(mOriginalDuration - currentPlayTime);
- setValues(startValue, toValue);
- start();
+ mAnimator.setDuration(mOriginalDuration - currentPlayTime);
+ mAnimator.setFloatValues(startValue, toValue);
+ mAnimator.start();
mFirstRun = false;
}
}
- @Override
public void cancel() {
- super.cancel();
+ mAnimator.cancel();
mDirection = STOPPED;
}
- @Override
public void end() {
- super.end();
+ mAnimator.end();
mDirection = STOPPED;
}
@@ -112,4 +114,8 @@ public class InterruptibleInOutAnimator extends ValueAnimator {
public Object getTag() {
return mTag;
}
+
+ public ValueAnimator getAnimator() {
+ return mAnimator;
+ }
}
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index d7c2f5bb5..6fcf4329b 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -318,8 +318,9 @@ public final class Launcher extends Activity
// animate the changing of the tab content by fading pages in and out
final int duration = 150;
final float alpha = mCustomizePagedView.getAlpha();
- ValueAnimator alphaAnim = new ObjectAnimator(duration, mCustomizePagedView,
+ ValueAnimator alphaAnim = ObjectAnimator.ofFloat(mCustomizePagedView,
"alpha", alpha, 0.0f);
+ alphaAnim.setDuration(duration);
alphaAnim.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
String tag = mHomeCustomizationDrawer.getCurrentTabTag();
@@ -341,8 +342,9 @@ public final class Launcher extends Activity
}
final float alpha = mCustomizePagedView.getAlpha();
- ValueAnimator alphaAnim = new ObjectAnimator(duration,
+ ValueAnimator alphaAnim = ObjectAnimator.ofFloat(
mCustomizePagedView, "alpha", alpha, 1.0f);
+ alphaAnim.setDuration(duration);
alphaAnim.start();
}
});
@@ -2284,7 +2286,8 @@ public final class Launcher extends Activity
getResources().getInteger(R.integer.config_toolbarButtonFadeOutTime);
if (seq != null) {
- Animator anim = new ObjectAnimator<Float>(duration, view, "alpha", show ? 1.0f : 0.0f);
+ Animator anim = ObjectAnimator.ofFloat(view, "alpha", show ? 1.0f : 0.0f);
+ anim.setDuration(duration);
anim.addListener(new AnimatorListenerAdapter() {
public void onAnimationStart(Animator animation) {
if (showing) showToolbarButton(view);
@@ -2383,9 +2386,10 @@ public final class Launcher extends Activity
}
if (animated) {
- ValueAnimator scaleAnim = new ObjectAnimator(duration, toView,
- new PropertyValuesHolder<Float>("scaleX", scale, 1.0f),
- new PropertyValuesHolder<Float>("scaleY", scale, 1.0f));
+ ValueAnimator scaleAnim = ObjectAnimator.ofPropertyValuesHolder(toView,
+ PropertyValuesHolder.ofFloat("scaleX", scale, 1.0f),
+ PropertyValuesHolder.ofFloat("scaleY", scale, 1.0f));
+ scaleAnim.setDuration(duration);
scaleAnim.setInterpolator(new DecelerateInterpolator());
scaleAnim.addListener(new AnimatorListenerAdapter() {
public void onAnimationStart(Animator animation) {
@@ -2445,9 +2449,10 @@ public final class Launcher extends Activity
if (animated) {
if (mStateAnimation != null) mStateAnimation.cancel();
mStateAnimation = new AnimatorSet();
- ValueAnimator scaleAnim = new ObjectAnimator(duration, fromView,
- new PropertyValuesHolder<Float>("scaleX", scaleFactor),
- new PropertyValuesHolder<Float>("scaleY", scaleFactor));
+ ValueAnimator scaleAnim = ObjectAnimator.ofPropertyValuesHolder(fromView,
+ PropertyValuesHolder.ofFloat("scaleX", scaleFactor),
+ PropertyValuesHolder.ofFloat("scaleY", scaleFactor));
+ scaleAnim.setDuration(duration);
scaleAnim.setInterpolator(new AccelerateInterpolator());
mStateAnimation.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
@@ -2522,10 +2527,13 @@ public final class Launcher extends Activity
AnimatorSet toolbarShowAnim = new AnimatorSet();
hideAndShowToolbarButtons(toState, toolbarShowAnim, toolbarHideAnim);
- mStateAnimation.playTogether(
- toolbarHideAnim,
- new ObjectAnimator(duration, fromView, "y", fromViewStartY, fromViewEndY),
- new ObjectAnimator(duration, toView, "y", toViewStartY, toViewEndY));
+ ObjectAnimator fromAnim = ObjectAnimator.ofFloat(fromView, "y",
+ fromViewStartY, fromViewEndY);
+ fromAnim.setDuration(duration);
+ ObjectAnimator toAnim = ObjectAnimator.ofFloat(toView, "y",
+ toViewStartY, toViewEndY);
+ fromAnim.setDuration(duration);
+ mStateAnimation.playTogether(toolbarHideAnim, fromAnim, toAnim);
// Show the new toolbar buttons just as the main animation is ending
final int fadeInTime = res.getInteger(R.integer.config_toolbarButtonFadeInTime);
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 75e39e0c6..4de182218 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -16,6 +16,7 @@
package com.android.launcher2;
+import android.animation.AnimatorListenerAdapter;
import com.android.launcher.R;
import android.animation.Animator;
@@ -80,8 +81,8 @@ public class Workspace extends SmoothPagedView
private static final int BACKGROUND_FADE_IN_DURATION = 100;
// These animators are used to fade the background
- private ObjectAnimator<Float> mBackgroundFadeInAnimation;
- private ObjectAnimator<Float> mBackgroundFadeOutAnimation;
+ private ObjectAnimator mBackgroundFadeInAnimation;
+ private ObjectAnimator mBackgroundFadeOutAnimation;
private float mBackgroundAlpha = 0;
private final WallpaperManager mWallpaperManager;
@@ -194,15 +195,13 @@ public class Workspace extends SmoothPagedView
LauncherApplication app = (LauncherApplication)context.getApplicationContext();
mIconCache = app.getIconCache();
- mUnshrinkAnimationListener = new AnimatorListener() {
+ mUnshrinkAnimationListener = new AnimatorListenerAdapter() {
public void onAnimationStart(Animator animation) {
mIsInUnshrinkAnimation = true;
}
public void onAnimationEnd(Animator animation) {
mIsInUnshrinkAnimation = false;
}
- public void onAnimationCancel(Animator animation) {}
- public void onAnimationRepeat(Animator animation) {}
};
mSnapVelocity = 600;
@@ -477,8 +476,8 @@ public class Workspace extends SmoothPagedView
if (!mIsSmall && !mIsInUnshrinkAnimation) {
if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel();
if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel();
- mBackgroundFadeInAnimation = new ObjectAnimator<Float>(BACKGROUND_FADE_IN_DURATION,
- this, new PropertyValuesHolder<Float>("backgroundAlpha", 1.0f));
+ mBackgroundFadeInAnimation = ObjectAnimator.ofFloat(this, "backgroundAlpha", 1.0f);
+ mBackgroundFadeInAnimation.setDuration(BACKGROUND_FADE_IN_DURATION);
mBackgroundFadeInAnimation.start();
}
}
@@ -487,8 +486,8 @@ public class Workspace extends SmoothPagedView
if (!mIsSmall && !mIsInUnshrinkAnimation) {
if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel();
if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel();
- mBackgroundFadeOutAnimation = new ObjectAnimator<Float>(BACKGROUND_FADE_OUT_DURATION,
- this, new PropertyValuesHolder<Float>("backgroundAlpha", 0.0f));
+ mBackgroundFadeOutAnimation = ObjectAnimator.ofFloat(this, "backgroundAlpha", 0.0f);
+ mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION);
mBackgroundFadeOutAnimation.setStartDelay(BACKGROUND_FADE_OUT_DELAY);
mBackgroundFadeOutAnimation.start();
}
@@ -750,16 +749,18 @@ public class Workspace extends SmoothPagedView
if (animated) {
final int duration = res.getInteger(R.integer.config_workspaceShrinkTime);
- new ObjectAnimator<Float>(duration, cl,
- new PropertyValuesHolder<Float>("x", newX),
- new PropertyValuesHolder<Float>("y", newY),
- new PropertyValuesHolder<Float>("scaleX",
+ ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(cl,
+ PropertyValuesHolder.ofFloat("x", newX),
+ PropertyValuesHolder.ofFloat("y", newY),
+ PropertyValuesHolder.ofFloat("scaleX",
SHRINK_FACTOR * rotationScaleX * extraShrinkFactor),
- new PropertyValuesHolder<Float>("scaleY",
+ PropertyValuesHolder.ofFloat("scaleY",
SHRINK_FACTOR * rotationScaleY * extraShrinkFactor),
- new PropertyValuesHolder<Float>("backgroundAlpha", finalAlpha),
- new PropertyValuesHolder<Float>("alpha", finalAlpha),
- new PropertyValuesHolder<Float>("rotationY", rotation)).start();
+ PropertyValuesHolder.ofFloat("backgroundAlpha", finalAlpha),
+ PropertyValuesHolder.ofFloat("alpha", finalAlpha),
+ PropertyValuesHolder.ofFloat("rotationY", rotation));
+ anim.setDuration(duration);
+ anim.start();
} else {
cl.setX((int)newX);
cl.setY((int)newY);
@@ -902,14 +903,15 @@ public class Workspace extends SmoothPagedView
}
if (animated) {
+
s.playTogether(
- new ObjectAnimator<Float>(duration, cl, "translationX", 0.0f),
- new ObjectAnimator<Float>(duration, cl, "translationY", 0.0f),
- new ObjectAnimator<Float>(duration, cl, "scaleX", 1.0f),
- new ObjectAnimator<Float>(duration, cl, "scaleY", 1.0f),
- new ObjectAnimator<Float>(duration, cl, "backgroundAlpha", 0.0f),
- new ObjectAnimator<Float>(duration, cl, "alpha", finalAlphaValue),
- new ObjectAnimator<Float>(duration, cl, "rotationY", rotation));
+ ObjectAnimator.ofFloat(cl, "translationX", 0.0f).setDuration(duration),
+ ObjectAnimator.ofFloat(cl, "translationY", 0.0f).setDuration(duration),
+ ObjectAnimator.ofFloat(cl, "scaleX", 1.0f).setDuration(duration),
+ ObjectAnimator.ofFloat(cl, "scaleY", 1.0f).setDuration(duration),
+ ObjectAnimator.ofFloat(cl, "backgroundAlpha", 0.0f).setDuration(duration),
+ ObjectAnimator.ofFloat(cl, "alpha", finalAlphaValue).setDuration(duration),
+ ObjectAnimator.ofFloat(cl, "rotationY", rotation).setDuration(duration));
} else {
cl.setTranslationX(0.0f);
cl.setTranslationY(0.0f);