Clean up memory leak in volume dialog
Fixes: 144843711 Test: dump java heap; open close volumedialog many times; take another java heap; compare Change-Id: I160d77822c9f0c4b15c83acad99dbe6e6d41d440
This commit is contained in:
@@ -43,6 +43,9 @@ public class ConfigurableTexts {
|
||||
|
||||
public int add(final TextView text, final int labelResId) {
|
||||
if (text == null) return 0;
|
||||
if (mTexts.containsKey(text)) {
|
||||
return mTexts.get(text);
|
||||
}
|
||||
final Resources res = mContext.getResources();
|
||||
final float fontScale = res.getConfiguration().fontScale;
|
||||
final float density = res.getDisplayMetrics().density;
|
||||
@@ -63,6 +66,11 @@ public class ConfigurableTexts {
|
||||
return sp;
|
||||
}
|
||||
|
||||
public void remove(final TextView text) {
|
||||
mTexts.remove(text);
|
||||
mTextLabels.remove(text);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
if (mTexts.isEmpty()) return;
|
||||
mTexts.keyAt(0).post(mUpdateAll);
|
||||
|
||||
@@ -922,6 +922,7 @@ public class VolumeDialogImpl implements VolumeDialog,
|
||||
if (!mDynamic.get(row.stream)) {
|
||||
mRows.remove(i);
|
||||
mDialogRowsView.removeView(row.view);
|
||||
mConfigurableTexts.remove(row.header);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user