From 1f553cfcf286874e154f61798fb01a5be48ce911 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Fri, 2 May 2014 12:01:36 +0200 Subject: [PATCH] Removed always running preDrawListener Replaced a always running preDrawListener with one which is just posted on demand. Change-Id: Ie7667302d848fe4a109c04dc91376f0b44d3acd3 --- .../stack/NotificationStackScrollLayout.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index 4c0962e5dd8dc..0114f3cd7ef0c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -106,15 +106,14 @@ public class NotificationStackScrollLayout extends ViewGroup private ExpandableView.OnHeightChangedListener mOnHeightChangedListener; private boolean mChildHierarchyDirty; private boolean mIsExpanded = true; - private boolean mChildrenNeedUpdate; - private ViewTreeObserver.OnPreDrawListener mPreDrawListener + private boolean mChildrenUpdateRequested; + private ViewTreeObserver.OnPreDrawListener mChildrenUpdater = new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { - if (mChildrenNeedUpdate) { - updateChildren(); - mChildrenNeedUpdate = false; - } + updateChildren(); + mChildrenUpdateRequested = false; + getViewTreeObserver().removeOnPreDrawListener(this); return true; } }; @@ -181,7 +180,6 @@ public class NotificationStackScrollLayout extends ViewGroup mPaddingBetweenElements = context.getResources() .getDimensionPixelSize(R.dimen.notification_padding); mStackScrollAlgorithm = new StackScrollAlgorithm(context); - getViewTreeObserver().addOnPreDrawListener(mPreDrawListener); } @Override @@ -275,8 +273,11 @@ public class NotificationStackScrollLayout extends ViewGroup } private void requestChildrenUpdate() { - mChildrenNeedUpdate = true; - invalidate(); + if (!mChildrenUpdateRequested) { + getViewTreeObserver().addOnPreDrawListener(mChildrenUpdater); + mChildrenUpdateRequested = true; + invalidate(); + } } private boolean isCurrentlyAnimating() {