diff options
author | Jorim Jaggi <jjaggi@google.com> | 2015-07-27 19:18:37 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-07-27 19:18:37 +0000 |
commit | 6a601960a3cbfbed1f0ac6df65791a3149eec92e (patch) | |
tree | 706ae800bec35e0966e85da5058566e366b6f077 /packages/SettingsLib | |
parent | da30e09b2be7d6bc3f27e6cec8c21bb1d7556537 (diff) | |
parent | 9e49b5d679672ea4a64382f9a36663c73603961b (diff) | |
download | frameworks_base-6a601960a3cbfbed1f0ac6df65791a3149eec92e.zip frameworks_base-6a601960a3cbfbed1f0ac6df65791a3149eec92e.tar.gz frameworks_base-6a601960a3cbfbed1f0ac6df65791a3149eec92e.tar.bz2 |
am 9e49b5d6: Merge "Move PIN/Pattern appear animation to RenderThread (1/2)" into mnc-dev
* commit '9e49b5d679672ea4a64382f9a36663c73603961b':
Move PIN/Pattern appear animation to RenderThread (1/2)
Diffstat (limited to 'packages/SettingsLib')
-rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java | 66 |
1 files changed, 56 insertions, 10 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java b/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java index 441474d..df76125 100644 --- a/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/animation/AppearAnimationUtils.java @@ -16,11 +16,18 @@ package com.android.settingslib.animation; +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.ObjectAnimator; +import android.animation.ValueAnimator; import android.content.Context; +import android.view.RenderNodeAnimator; import android.view.View; +import android.view.ViewPropertyAnimator; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; +import com.android.internal.widget.LockPatternView; import com.android.settingslib.R; /** @@ -174,24 +181,63 @@ public class AppearAnimationUtils implements AppearAnimationCreator<View> { } @Override - public void createAnimation(View view, long delay, long duration, float translationY, - boolean appearing, Interpolator interpolator, Runnable endRunnable) { + public void createAnimation(final View view, long delay, long duration, float translationY, + boolean appearing, Interpolator interpolator, final Runnable endRunnable) { if (view != null) { view.setAlpha(appearing ? 0f : 1.0f); view.setTranslationY(appearing ? translationY : 0); - view.animate() - .alpha(appearing ? 1f : 0f) - .translationY(appearing ? 0 : translationY) - .setInterpolator(interpolator) - .setDuration(duration) - .setStartDelay(delay); + Animator alphaAnim; + float targetAlpha = appearing ? 1f : 0f; + if (view.isHardwareAccelerated()) { + RenderNodeAnimator alphaAnimRt = new RenderNodeAnimator(RenderNodeAnimator.ALPHA, + targetAlpha); + alphaAnimRt.setTarget(view); + alphaAnim = alphaAnimRt; + } else { + alphaAnim = ObjectAnimator.ofFloat(view, View.ALPHA, view.getAlpha(), targetAlpha); + } + alphaAnim.setInterpolator(interpolator); + alphaAnim.setDuration(duration); + alphaAnim.setStartDelay(delay); if (view.hasOverlappingRendering()) { - view.animate().withLayer(); + view.setLayerType(View.LAYER_TYPE_HARDWARE, null); + alphaAnim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + view.setLayerType(View.LAYER_TYPE_NONE, null); + } + }); } if (endRunnable != null) { - view.animate().withEndAction(endRunnable); + alphaAnim.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + endRunnable.run(); + } + }); } + alphaAnim.start(); + startTranslationYAnimation(view, delay, duration, appearing ? 0 : translationY, + interpolator); + } + } + + public static void startTranslationYAnimation(View view, long delay, long duration, + float endTranslationY, Interpolator interpolator) { + Animator translationAnim; + if (view.isHardwareAccelerated()) { + RenderNodeAnimator translationAnimRt = new RenderNodeAnimator( + RenderNodeAnimator.TRANSLATION_Y, endTranslationY); + translationAnimRt.setTarget(view); + translationAnim = translationAnimRt; + } else { + translationAnim = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, + view.getTranslationY(), endTranslationY); } + translationAnim.setInterpolator(interpolator); + translationAnim.setDuration(duration); + translationAnim.setStartDelay(delay); + translationAnim.start(); } public class AppearAnimationProperties { |