Merge "Clean up memory leak in volume dialog"

This commit is contained in:
TreeHugger Robot
2019-12-04 16:03:25 +00:00
committed by Android (Google) Code Review
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);
}
}
}