summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Selim Cinek <cinek@google.com> 2018-04-25 13:10:57 +0800
committer Selim Cinek <cinek@google.com> 2018-04-25 14:34:48 +0800
commit85845b8458d8a6950b4ac87bcd59cbfb85680525 (patch)
tree3d0e745ac1ab3ffb11ce0124a2feb4ee7b0519c3
parent1c72fa0249c364143d0818d129b6dc7f70054752 (diff)
Fixed a leak of preDrawlisteners when an icon was animating when detached
Test: add notification, observe clipping on icons still normally Change-Id: I5b2eec3988c645b66185f2890ab0cb8910ddeacd Fixes: 73961798
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
index 44136c58875d..d3caf0351d03 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
@@ -407,13 +407,14 @@ public class NotificationShelf extends ActivatableNotificationView implements
boolean needsContinuousClipping = ViewState.isAnimatingY(icon) && !mAmbientState.isDark();
boolean isContinuousClipping = icon.getTag(TAG_CONTINUOUS_CLIPPING) != null;
if (needsContinuousClipping && !isContinuousClipping) {
+ final ViewTreeObserver observer = icon.getViewTreeObserver();
ViewTreeObserver.OnPreDrawListener predrawListener =
new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
boolean animatingY = ViewState.isAnimatingY(icon);
- if (!animatingY || !icon.isAttachedToWindow()) {
- icon.getViewTreeObserver().removeOnPreDrawListener(this);
+ if (!animatingY) {
+ observer.removeOnPreDrawListener(this);
icon.setTag(TAG_CONTINUOUS_CLIPPING, null);
return true;
}
@@ -421,7 +422,20 @@ public class NotificationShelf extends ActivatableNotificationView implements
return true;
}
};
- icon.getViewTreeObserver().addOnPreDrawListener(predrawListener);
+ observer.addOnPreDrawListener(predrawListener);
+ icon.addOnAttachStateChangeListener(new OnAttachStateChangeListener() {
+ @Override
+ public void onViewAttachedToWindow(View v) {
+ }
+
+ @Override
+ public void onViewDetachedFromWindow(View v) {
+ if (v == icon) {
+ observer.removeOnPreDrawListener(predrawListener);
+ icon.setTag(TAG_CONTINUOUS_CLIPPING, null);
+ }
+ }
+ });
icon.setTag(TAG_CONTINUOUS_CLIPPING, predrawListener);
}
}