summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2017-03-15 14:41:18 -0700
committerTony Wickham <twickham@google.com>2017-03-15 14:46:02 -0700
commit81ebe383f5c9ef9ebff7fefe641469e74ec44f23 (patch)
treef37bf3d42de1d49a2ef4e5337cf1b3eb43cdda25
parenta431fbb85090b180673c38b6d88f492a805282d6 (diff)
downloadandroid_packages_apps_Trebuchet-81ebe383f5c9ef9ebff7fefe641469e74ec44f23.tar.gz
android_packages_apps_Trebuchet-81ebe383f5c9ef9ebff7fefe641469e74ec44f23.tar.bz2
android_packages_apps_Trebuchet-81ebe383f5c9ef9ebff7fefe641469e74ec44f23.zip
Small cleanup for notifications
- Add null check when collapsing footer, as container could be null if the app is opened - Remove redundant method that always passed mNotificationItemView - Set mNotificationItemView to null when it is removed Change-Id: Ia329815224b213fc688733eaaf6f29ee6888caaf
-rw-r--r--src/com/android/launcher3/notification/NotificationFooterLayout.java20
-rw-r--r--src/com/android/launcher3/notification/NotificationItemView.java3
-rw-r--r--src/com/android/launcher3/popup/PopupContainerWithArrow.java15
3 files changed, 17 insertions, 21 deletions
diff --git a/src/com/android/launcher3/notification/NotificationFooterLayout.java b/src/com/android/launcher3/notification/NotificationFooterLayout.java
index 2e803417d..1eef743fe 100644
--- a/src/com/android/launcher3/notification/NotificationFooterLayout.java
+++ b/src/com/android/launcher3/notification/NotificationFooterLayout.java
@@ -198,15 +198,17 @@ public class NotificationFooterLayout extends FrameLayout {
// There are no more icons in the footer, so hide it.
PopupContainerWithArrow popup = PopupContainerWithArrow.getOpen(
Launcher.getLauncher(getContext()));
- Animator collapseFooter = popup.reduceNotificationViewHeight(getHeight(),
- getResources().getInteger(R.integer.config_removeNotificationViewDuration));
- collapseFooter.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- ((ViewGroup) getParent()).removeView(NotificationFooterLayout.this);
- }
- });
- collapseFooter.start();
+ if (popup != null) {
+ Animator collapseFooter = popup.reduceNotificationViewHeight(getHeight(),
+ getResources().getInteger(R.integer.config_removeNotificationViewDuration));
+ collapseFooter.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ ((ViewGroup) getParent()).removeView(NotificationFooterLayout.this);
+ }
+ });
+ collapseFooter.start();
+ }
}
}
diff --git a/src/com/android/launcher3/notification/NotificationItemView.java b/src/com/android/launcher3/notification/NotificationItemView.java
index a34074271..c6268e27d 100644
--- a/src/com/android/launcher3/notification/NotificationItemView.java
+++ b/src/com/android/launcher3/notification/NotificationItemView.java
@@ -23,7 +23,6 @@ import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.FrameLayout;
import com.android.launcher3.ItemInfo;
@@ -85,8 +84,6 @@ public class NotificationItemView extends PopupItemView implements LogContainerP
MeasureSpec.makeMeasureSpec(newHeight, MeasureSpec.EXACTLY));
initializeBackgroundClipping(true /* force */);
invalidate();
- } else {
- ((ViewGroup) getParent()).removeView(NotificationItemView.this);
}
}
});
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index b8d38f587..1eac07608 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -568,7 +568,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));
+ mNotificationItemView.getHeight() + spacing, duration));
final View removeMarginView = mIsAboveIcon ? getItemViewAt(getItemCount() - 2)
: mNotificationItemView;
if (removeMarginView != null) {
@@ -588,6 +588,7 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
@Override
public void onAnimationEnd(Animator animation) {
removeView(mNotificationItemView);
+ mNotificationItemView = null;
if (getItemCount() == 0) {
close(false);
return;
@@ -612,19 +613,19 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
return LauncherAnimUtils.ofPropertyValuesHolder(
mArrow, new PropertyListBuilder().scale(scale).build());
}
+
/**
* Animates the height of the notification item and the translationY of other items accordingly.
*/
- public Animator reduceNotificationViewHeight(int heightToRemove, int duration,
- NotificationItemView notificationItem) {
+ public Animator reduceNotificationViewHeight(int heightToRemove, int duration) {
final int translateYBy = mIsAboveIcon ? heightToRemove : -heightToRemove;
AnimatorSet animatorSet = LauncherAnimUtils.createAnimatorSet();
- animatorSet.play(notificationItem.animateHeightRemoval(heightToRemove));
+ animatorSet.play(mNotificationItemView.animateHeightRemoval(heightToRemove));
PropertyResetListener<View, Float> resetTranslationYListener
= new PropertyResetListener<>(TRANSLATION_Y, 0f);
for (int i = 0; i < getItemCount(); i++) {
final PopupItemView itemView = getItemViewAt(i);
- if (!mIsAboveIcon && itemView == notificationItem) {
+ if (!mIsAboveIcon && itemView == mNotificationItemView) {
// The notification view is already in the right place when container is below icon.
continue;
}
@@ -647,10 +648,6 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
return animatorSet;
}
- public Animator reduceNotificationViewHeight(int heightToRemove, int duration) {
- return reduceNotificationViewHeight(heightToRemove, duration, mNotificationItemView);
- }
-
@Override
public boolean supportsAppInfoDropTarget() {
return true;