Преглед изворни кода

Merge pull request #253 from Unpublished/ListPreference

Simplify and match stock behaviour
Aidan Follestad пре 10 година
родитељ
комит
9c5f4d74cb

+ 2 - 11
library/src/main/java/com/afollestad/materialdialogs/prefs/MaterialListPreference.java

@@ -31,20 +31,11 @@ public class MaterialListPreference extends ListPreference {
 
     @Override
     protected void showDialog(Bundle state) {
-        int preselect = -1;
-        if (getEntryValues() != null) {
-            for (int i = 0; i < getEntryValues().length; i++) {
-                if (getValue() != null && getValue().equals(getEntryValues()[i])) {
-                    preselect = i;
-                    break;
-                }
-            }
-        }
+        int preselect = findIndexOfValue(getValue());
 
         mBuilder = new MaterialDialog.Builder(context)
                 .title(getTitle())
                 .icon(getDialogIcon())
-                .positiveText(getPositiveButtonText())
                 .negativeText(getNegativeButtonText())
                 .items(getEntries())
                 .itemsCallbackSingleChoice(preselect, new MaterialDialog.ListCallback() {
@@ -70,4 +61,4 @@ public class MaterialListPreference extends ListPreference {
 
         mBuilder.show();
     }
-}
+}