|
@@ -31,20 +31,11 @@ public class MaterialListPreference extends ListPreference {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected void showDialog(Bundle state) {
|
|
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)
|
|
mBuilder = new MaterialDialog.Builder(context)
|
|
.title(getTitle())
|
|
.title(getTitle())
|
|
.icon(getDialogIcon())
|
|
.icon(getDialogIcon())
|
|
- .positiveText(getPositiveButtonText())
|
|
|
|
.negativeText(getNegativeButtonText())
|
|
.negativeText(getNegativeButtonText())
|
|
.items(getEntries())
|
|
.items(getEntries())
|
|
.itemsCallbackSingleChoice(preselect, new MaterialDialog.ListCallback() {
|
|
.itemsCallbackSingleChoice(preselect, new MaterialDialog.ListCallback() {
|
|
@@ -70,4 +61,4 @@ public class MaterialListPreference extends ListPreference {
|
|
|
|
|
|
mBuilder.show();
|
|
mBuilder.show();
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|