diff options
author | Tony Wickham <twickham@google.com> | 2017-05-02 21:09:25 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-05-02 21:09:27 +0000 |
commit | aaff476c3def4ba76173f87b47486eeebeebe57e (patch) | |
tree | 5f9fb4fa5c14d181d3f3af2389d99a479a33234c | |
parent | 2bb1e74ccf780cf514e25eaa349448cf318de42f (diff) | |
parent | 24ba787ded0391d37327b972ca850b2710124a71 (diff) | |
download | android_packages_apps_Trebuchet-aaff476c3def4ba76173f87b47486eeebeebe57e.tar.gz android_packages_apps_Trebuchet-aaff476c3def4ba76173f87b47486eeebeebe57e.tar.bz2 android_packages_apps_Trebuchet-aaff476c3def4ba76173f87b47486eeebeebe57e.zip |
Merge "Handle back-to-back height reduction animations" into ub-launcher3-dorval
-rw-r--r-- | src/com/android/launcher3/notification/NotificationItemView.java | 5 | ||||
-rw-r--r-- | src/com/android/launcher3/popup/PopupContainerWithArrow.java | 33 |
2 files changed, 24 insertions, 14 deletions
diff --git a/src/com/android/launcher3/notification/NotificationItemView.java b/src/com/android/launcher3/notification/NotificationItemView.java index 5e8e2c768..e5bf35a1e 100644 --- a/src/com/android/launcher3/notification/NotificationItemView.java +++ b/src/com/android/launcher3/notification/NotificationItemView.java @@ -76,6 +76,11 @@ public class NotificationItemView extends PopupItemView implements LogContainerP mSwipeHelper.setDisableHardwareLayers(true); } + public int getHeightMinusFooter() { + int footerHeight = mFooter.getParent() == null ? 0 : mFooter.getHeight(); + return getHeight() - footerHeight; + } + public Animator animateHeightRemoval(int heightToRemove) { final int newHeight = getHeight() - heightToRemove; return new PillHeightRevealOutlineProvider(mPillRect, diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index dc7fa05f7..fb7f80ceb 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -107,6 +107,7 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra protected Animator mOpenCloseAnimator; private boolean mDeferContainerRemoval; + private AnimatorSet mReduceHeightAnimatorSet; public PopupContainerWithArrow(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); @@ -584,7 +585,7 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra R.integer.config_removeNotificationViewDuration); final int spacing = getResources().getDimensionPixelSize(R.dimen.popup_items_spacing); removeNotification.play(reduceNotificationViewHeight( - mNotificationItemView.getHeight() + spacing, duration)); + mNotificationItemView.getHeightMinusFooter() + spacing, duration)); final View removeMarginView = mIsAboveIcon ? getItemViewAt(getItemCount() - 2) : mNotificationItemView; if (removeMarginView != null) { @@ -642,9 +643,12 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra * Animates the height of the notification item and the translationY of other items accordingly. */ public Animator reduceNotificationViewHeight(int heightToRemove, int duration) { + if (mReduceHeightAnimatorSet != null) { + mReduceHeightAnimatorSet.cancel(); + } final int translateYBy = mIsAboveIcon ? heightToRemove : -heightToRemove; - AnimatorSet animatorSet = LauncherAnimUtils.createAnimatorSet(); - animatorSet.play(mNotificationItemView.animateHeightRemoval(heightToRemove)); + mReduceHeightAnimatorSet = LauncherAnimUtils.createAnimatorSet(); + mReduceHeightAnimatorSet.play(mNotificationItemView.animateHeightRemoval(heightToRemove)); PropertyResetListener<View, Float> resetTranslationYListener = new PropertyResetListener<>(TRANSLATION_Y, 0f); for (int i = 0; i < getItemCount(); i++) { @@ -656,20 +660,21 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra ValueAnimator translateItem = ObjectAnimator.ofFloat(itemView, TRANSLATION_Y, itemView.getTranslationY() + translateYBy).setDuration(duration); translateItem.addListener(resetTranslationYListener); - animatorSet.play(translateItem); + mReduceHeightAnimatorSet.play(translateItem); } - if (mIsAboveIcon) { - // All the items, including the notification item, translated down, but the - // container itself did not. This means the items would jump back to their - // original translation unless we update the container's translationY here. - animatorSet.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { + mReduceHeightAnimatorSet.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + if (mIsAboveIcon) { + // All the items, including the notification item, translated down, but the + // container itself did not. This means the items would jump back to their + // original translation unless we update the container's translationY here. setTranslationY(getTranslationY() + translateYBy); } - }); - } - return animatorSet; + mReduceHeightAnimatorSet = null; + } + }); + return mReduceHeightAnimatorSet; } @Override |