Переглянути джерело

Merge pull request #54 from jrgonzalezg/master

Fixed issue with callbacks not being called when there was no positive button...
Aidan Follestad 10 роки тому
батько
коміт
44ddfbb3bf

+ 6 - 4
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -515,15 +515,17 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
                 if (!cb.isChecked())
                     cb.setChecked(true);
                 invalidateSingleChoice(index);
-                if (!hasActionButtons()) {
-                    // Immediately send the selection callback without dismissing if no action buttons are shown
+                if (positiveText == null) {
+                    // Immediately send the selection callback if no positive button is shown
+                    if (autoDismiss) dismiss();
                     sendSingleChoiceCallback(v);
                 }
             } else if (listCallbackMulti != null) {
                 CheckBox cb = (CheckBox) ((LinearLayout) v).getChildAt(0);
                 cb.setChecked(!cb.isChecked());
-                if (!hasActionButtons()) {
-                    // Immediately send the selection callback without dismissing if no action buttons are shown
+                if (positiveText == null) {
+                    // Immediately send the selection callback if no positive button is shown
+                    if (autoDismiss) dismiss();
                     sendMultichoiceCallback();
                 }
             } else if (autoDismiss) dismiss();