Bug 1403347: Don't cache CustomListPreference dialog items. r=liuche draft
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 26 Sep 2017 16:23:59 -0700
changeset 670853 337fcaec7eafeaa872173eb50b14b3dbb9067b90
parent 670852 3cc0d80e9fa5d569320b8ebbf583204dbb7dd467
child 733337 d420d4aa439c18d67c433545848165d1e87b665a
push id81740
push usermichael.l.comella@gmail.com
push dateTue, 26 Sep 2017 23:57:01 +0000
reviewersliuche
bugs1403347, 1403139
milestone58.0a1
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
mobile/android/base/java/org/mozilla/gecko/preferences/CustomListPreference.java
--- 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);
             }
         });