diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 45a9e3118f..438a5d9091 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -2236,13 +2236,10 @@ public final class Launcher extends Activity toView.setVisibility(View.VISIBLE); toView.setAlpha(0f); - ValueAnimator alphaAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(fadeDuration); + final ObjectAnimator alphaAnim = ObjectAnimator + .ofFloat(toView, "alpha", 0f, 1f) + .setDuration(fadeDuration); alphaAnim.setInterpolator(new DecelerateInterpolator(1.5f)); - alphaAnim.addUpdateListener(new LauncherAnimatorUpdateListener() { - public void onAnimationUpdate(float a, float b) { - toView.setAlpha(a * 0f + b * 1f); - } - }); // toView should appear right at the end of the workspace shrink // animation @@ -2264,11 +2261,6 @@ public final class Launcher extends Activity } @Override public void onAnimationEnd(Animator animation) { - // If we don't set the final scale values here, if this animation is cancelled - // it will have the wrong scale value and subsequent cameraPan animations will - // not fix that - toView.setScaleX(1.0f); - toView.setScaleY(1.0f); if (toView instanceof LauncherTransitionable) { ((LauncherTransitionable) toView).onLauncherTransitionEnd(instance, scaleAnim, false); @@ -2365,6 +2357,8 @@ public final class Launcher extends Activity final Launcher instance = this; final int duration = res.getInteger(R.integer.config_appsCustomizeZoomOutTime); + final int fadeOutDuration = + res.getInteger(R.integer.config_appsCustomizeFadeOutTime); final float scaleFactor = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor); final View fromView = mAppsCustomizeTabHost; @@ -2386,22 +2380,18 @@ public final class Launcher extends Activity final float oldScaleX = fromView.getScaleX(); final float oldScaleY = fromView.getScaleY(); - ValueAnimator scaleAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration); - scaleAnim.setInterpolator(new Workspace.ZoomInInterpolator()); - scaleAnim.addUpdateListener(new LauncherAnimatorUpdateListener() { - public void onAnimationUpdate(float a, float b) { - fromView.setScaleX(a * oldScaleX + b * scaleFactor); - fromView.setScaleY(a * oldScaleY + b * scaleFactor); - } - }); - final ValueAnimator alphaAnim = ValueAnimator.ofFloat(0f, 1f); - alphaAnim.setDuration(res.getInteger(R.integer.config_appsCustomizeFadeOutTime)); + final LauncherViewPropertyAnimator scaleAnim = + new LauncherViewPropertyAnimator(fromView); + scaleAnim. + scaleX(scaleFactor).scaleY(scaleFactor). + setDuration(duration). + setInterpolator(new Workspace.ZoomInInterpolator()); + + final ObjectAnimator alphaAnim = ObjectAnimator + .ofFloat(fromView, "alpha", 1f, 0f) + .setDuration(fadeOutDuration); alphaAnim.setInterpolator(new AccelerateDecelerateInterpolator()); - alphaAnim.addUpdateListener(new LauncherAnimatorUpdateListener() { - public void onAnimationUpdate(float a, float b) { - fromView.setAlpha(a * 1f + b * 0f); - } - }); + if (fromView instanceof LauncherTransitionable) { ((LauncherTransitionable) fromView).onLauncherTransitionStart(instance, alphaAnim, true); diff --git a/src/com/android/launcher2/LauncherViewPropertyAnimator.java b/src/com/android/launcher2/LauncherViewPropertyAnimator.java index b31179d6ab..88b4cb4b8a 100644 --- a/src/com/android/launcher2/LauncherViewPropertyAnimator.java +++ b/src/com/android/launcher2/LauncherViewPropertyAnimator.java @@ -50,19 +50,17 @@ public class LauncherViewPropertyAnimator extends Animator implements AnimatorLi long mStartDelay; long mDuration; TimeInterpolator mInterpolator; - Animator.AnimatorListener mListener; + ArrayList mListeners; boolean mRunning = false; public LauncherViewPropertyAnimator(View target) { mTarget = target; + mListeners = new ArrayList(); } @Override public void addListener(Animator.AnimatorListener listener) { - if (mListener != null) { - throw new RuntimeException("Only one listener supported"); - } - mListener = listener; + mListeners.add(listener); } @Override @@ -89,7 +87,7 @@ public class LauncherViewPropertyAnimator extends Animator implements AnimatorLi @Override public ArrayList getListeners() { - return null; + return mListeners; } @Override @@ -99,31 +97,35 @@ public class LauncherViewPropertyAnimator extends Animator implements AnimatorLi @Override public void onAnimationCancel(Animator animation) { - if (mListener != null) { - mListener.onAnimationCancel(this); + for (int i = 0; i < mListeners.size(); i++) { + Animator.AnimatorListener listener = mListeners.get(i); + listener.onAnimationCancel(this); } mRunning = false; } @Override public void onAnimationEnd(Animator animation) { - if (mListener != null) { - mListener.onAnimationEnd(this); + for (int i = 0; i < mListeners.size(); i++) { + Animator.AnimatorListener listener = mListeners.get(i); + listener.onAnimationEnd(this); } mRunning = false; } @Override public void onAnimationRepeat(Animator animation) { - if (mListener != null) { - mListener.onAnimationRepeat(this); + for (int i = 0; i < mListeners.size(); i++) { + Animator.AnimatorListener listener = mListeners.get(i); + listener.onAnimationRepeat(this); } } @Override public void onAnimationStart(Animator animation) { - if (mListener != null) { - mListener.onAnimationStart(this); + for (int i = 0; i < mListeners.size(); i++) { + Animator.AnimatorListener listener = mListeners.get(i); + listener.onAnimationStart(this); } mRunning = true; } @@ -140,16 +142,12 @@ public class LauncherViewPropertyAnimator extends Animator implements AnimatorLi @Override public void removeAllListeners() { - mListener = null; + mListeners.clear(); } @Override public void removeListener(Animator.AnimatorListener listener) { - if (mListener == listener) { - mListener = null; - } else { - throw new RuntimeException("Removing listener that wasn't set"); - } + mListeners.remove(listener); } @Override