We reduce the height of the notification item when the second to last
notification is dismissed (to remove the unused footer) and when the
last notification is removed (to remove the unused notification item).
If the former is runninng when the latter starts, the end result is
janky because we weren't properly cleaning up the first animation when
the second began. We now cancel the existing animation before starting
the second.
Bug:
36172954
Change-Id: I742c15b6f59874bc675b4c20a83e9578ac5e5387
mSwipeHelper.setDisableHardwareLayers(true);
}
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,
public Animator animateHeightRemoval(int heightToRemove) {
final int newHeight = getHeight() - heightToRemove;
return new PillHeightRevealOutlineProvider(mPillRect,
protected Animator mOpenCloseAnimator;
private boolean mDeferContainerRemoval;
protected Animator mOpenCloseAnimator;
private boolean mDeferContainerRemoval;
+ private AnimatorSet mReduceHeightAnimatorSet;
public PopupContainerWithArrow(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
public PopupContainerWithArrow(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
R.integer.config_removeNotificationViewDuration);
final int spacing = getResources().getDimensionPixelSize(R.dimen.popup_items_spacing);
removeNotification.play(reduceNotificationViewHeight(
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) {
final View removeMarginView = mIsAboveIcon ? getItemViewAt(getItemCount() - 2)
: mNotificationItemView;
if (removeMarginView != null) {
* Animates the height of the notification item and the translationY of other items accordingly.
*/
public Animator reduceNotificationViewHeight(int heightToRemove, int duration) {
* 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;
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++) {
PropertyResetListener<View, Float> resetTranslationYListener
= new PropertyResetListener<>(TRANSLATION_Y, 0f);
for (int i = 0; i < getItemCount(); i++) {
ValueAnimator translateItem = ObjectAnimator.ofFloat(itemView, TRANSLATION_Y,
itemView.getTranslationY() + translateYBy).setDuration(duration);
translateItem.addListener(resetTranslationYListener);
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);
}
setTranslationY(getTranslationY() + translateYBy);
}
- });
- }
- return animatorSet;
+ mReduceHeightAnimatorSet = null;
+ }
+ });
+ return mReduceHeightAnimatorSet;