Merge "Fixed a few memory leaks in SystemUI" into nyc-dev

This commit is contained in:
Selim Cinek
2016-05-27 18:58:55 +00:00
committed by Android (Google) Code Review
3 changed files with 10 additions and 8 deletions

View File

@@ -360,7 +360,9 @@ public class NotificationContentView extends FrameLayout {
private void setVisible(final boolean isVisible) { private void setVisible(final boolean isVisible) {
if (isVisible) { if (isVisible) {
// This call can happen multiple times, but removing only removes a single one.
// We therefore need to remove the old one.
getViewTreeObserver().removeOnPreDrawListener(mEnableAnimationPredrawListener);
// We only animate if we are drawn at least once, otherwise the view might animate when // We only animate if we are drawn at least once, otherwise the view might animate when
// it's shown the first time // it's shown the first time
getViewTreeObserver().addOnPreDrawListener(mEnableAnimationPredrawListener); getViewTreeObserver().addOnPreDrawListener(mEnableAnimationPredrawListener);

View File

@@ -109,9 +109,6 @@ public class HeaderTransformState extends TransformState {
@Override @Override
public void recycle() { public void recycle() {
super.recycle(); super.recycle();
if (mWorkProfileState != null) {
mWorkProfileState.recycle();
}
sInstancePool.release(this); sInstancePool.release(this);
} }
@@ -120,6 +117,10 @@ public class HeaderTransformState extends TransformState {
super.reset(); super.reset();
mExpandButton = null; mExpandButton = null;
mWorkProfileState = null; mWorkProfileState = null;
if (mWorkProfileState != null) {
mWorkProfileState.recycle();
mWorkProfileState = null;
}
} }
public void setVisible(boolean visible) { public void setVisible(boolean visible) {

View File

@@ -26,9 +26,8 @@ import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.ExpandableNotificationRow; import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.ExpandableView; import com.android.systemui.statusbar.ExpandableView;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.WeakHashMap;
/** /**
* A state of a {@link com.android.systemui.statusbar.stack.NotificationStackScrollLayout} which * A state of a {@link com.android.systemui.statusbar.stack.NotificationStackScrollLayout} which
@@ -39,12 +38,12 @@ public class StackScrollState {
private static final String CHILD_NOT_FOUND_TAG = "StackScrollStateNoSuchChild"; private static final String CHILD_NOT_FOUND_TAG = "StackScrollStateNoSuchChild";
private final ViewGroup mHostView; private final ViewGroup mHostView;
private Map<ExpandableView, StackViewState> mStateMap; private WeakHashMap<ExpandableView, StackViewState> mStateMap;
private final int mClearAllTopPadding; private final int mClearAllTopPadding;
public StackScrollState(ViewGroup hostView) { public StackScrollState(ViewGroup hostView) {
mHostView = hostView; mHostView = hostView;
mStateMap = new HashMap<ExpandableView, StackViewState>(); mStateMap = new WeakHashMap<>();
mClearAllTopPadding = hostView.getContext().getResources().getDimensionPixelSize( mClearAllTopPadding = hostView.getContext().getResources().getDimensionPixelSize(
R.dimen.clear_all_padding_top); R.dimen.clear_all_padding_top);
} }