diff options
author | Yorke Lee <yorkelee@google.com> | 2015-03-27 22:27:35 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-03-27 22:27:36 +0000 |
commit | 1143f3077c8d1d7ca3ff162723d75ead0a3f780e (patch) | |
tree | 16f33f8b3a02cccf201a89c4160201f9184fe1bb /InCallUI/src/com/android/incallui/CallCardFragment.java | |
parent | b47803f0420649d495db546944d42849225712e0 (diff) | |
parent | 7e9763e4b3806c9edaf3df4f59a3d5a6452a361c (diff) |
Merge "Fix some jank during shrink animation"
Diffstat (limited to 'InCallUI/src/com/android/incallui/CallCardFragment.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/CallCardFragment.java | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 94e4ef161..af588767d 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -21,6 +21,8 @@ import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.LayoutTransition; import android.animation.ObjectAnimator; +import android.animation.ValueAnimator; +import android.animation.ValueAnimator.AnimatorUpdateListener; import android.app.Activity; import android.content.Context; import android.content.res.Configuration; @@ -110,6 +112,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr private Animation mPulseAnimation; private int mVideoAnimationDuration; + // Whether or not the call card is currently in the process of an animation + private boolean mIsAnimating; private MaterialPalette mCurrentThemeColors; @@ -601,6 +605,10 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mInCallMessageLabel.setVisibility(View.VISIBLE); } + public boolean isAnimating() { + return mIsAnimating; + } + private void showInternetCallLabel(boolean show) { if (show) { final String label = getView().getContext().getString( @@ -864,6 +872,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr final LayoutTransition transition = mPrimaryCallInfo.getLayoutTransition(); transition.disableTransitionType(LayoutTransition.CHANGING); + mIsAnimating = true; + observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { @@ -892,6 +902,13 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mCallTypeLabel.setAlpha(0); mCallNumberAndLabel.setAlpha(0); + assignTranslateAnimation(mCallStateLabel, 1); + assignTranslateAnimation(mCallStateIcon, 1); + assignTranslateAnimation(mPrimaryName, 2); + assignTranslateAnimation(mCallNumberAndLabel, 3); + assignTranslateAnimation(mCallTypeLabel, 4); + assignTranslateAnimation(mCallButtonsContainer, 5); + final Animator animator = getShrinkAnimator(parent.getHeight(), originalHeight); animator.addListener(new AnimatorListenerAdapter() { @@ -900,6 +917,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr mPrimaryCallCardContainer.setTag(R.id.view_tag_callcard_actual_height, null); setViewStatePostAnimation(listener); + mIsAnimating = false; + InCallPresenter.getInstance().onShrinkAnimationComplete(); } }); animator.start(); @@ -988,19 +1007,12 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr * and then translated upwards together with the scrim. */ private Animator getShrinkAnimator(int startHeight, int endHeight) { - final Animator shrinkAnimator = + final ObjectAnimator shrinkAnimator = ObjectAnimator.ofInt(mPrimaryCallCardContainer, "bottom", startHeight, endHeight); shrinkAnimator.setDuration(mShrinkAnimationDuration); shrinkAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { - assignTranslateAnimation(mCallStateLabel, 1); - assignTranslateAnimation(mCallStateIcon, 1); - assignTranslateAnimation(mPrimaryName, 2); - assignTranslateAnimation(mCallNumberAndLabel, 3); - assignTranslateAnimation(mCallTypeLabel, 4); - assignTranslateAnimation(mCallButtonsContainer, 5); - mFloatingActionButton.setEnabled(true); } }); @@ -1009,6 +1021,8 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } private void assignTranslateAnimation(View view, int offset) { + view.setLayerType(View.LAYER_TYPE_HARDWARE, null); + view.buildLayer(); view.setTranslationY(mTranslationOffset * offset); view.animate().translationY(0).alpha(1).withLayer() .setDuration(mShrinkAnimationDuration).setInterpolator(AnimUtils.EASE_IN); |