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:
Julia Reynolds
2019-12-02 13:20:42 -05:00
parent 426e4c1b5a
commit 20ad4dabac
2 changed files with 9 additions and 0 deletions

View File

@@ -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);

View File

@@ -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);
}
}
}