Bug 1403347: Don't cache CustomListPreference dialog items. r=liuche
We're returning a list of only a few items that, at worst, reads from
resources and is infrequently accessed: there is no reason to cache these
values and the bugs, like this one, that caches entail.
At the end of this patch, there's no crash, but the scrolling behavior isn't
great: that's
bug 1403139.
MozReview-Commit-ID: 3zoXWk78cM4
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/CustomListPreference.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/CustomListPreference.java
@@ -92,35 +92,28 @@ public abstract class CustomListPreferen
setOrder(0);
setSummary(LABEL_IS_DEFAULT);
} else {
setOrder(1);
setSummary("");
}
}
- private String[] getCachedDialogItems() {
- if (mDialogItems == null) {
- mDialogItems = createDialogItems();
- }
- return mDialogItems;
- }
-
/**
* Returns the strings to be displayed in the dialog.
*/
abstract protected String[] createDialogItems();
/**
* Display a dialog for this preference, when the preference is clicked.
*/
public void showDialog() {
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(getTitle().toString());
- builder.setItems(getCachedDialogItems(), new DialogInterface.OnClickListener() {
+ builder.setItems(createDialogItems(), new DialogInterface.OnClickListener() {
// Forward relevant events to the container class for handling.
@Override
public void onClick(DialogInterface dialog, int indexClicked) {
hideDialog();
onDialogIndexClicked(indexClicked);
}
});