|
@@ -71,6 +71,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
|
|
protected View negativeButton;
|
|
protected View negativeButton;
|
|
protected boolean isStacked;
|
|
protected boolean isStacked;
|
|
protected boolean alwaysCallMultiChoiceCallback;
|
|
protected boolean alwaysCallMultiChoiceCallback;
|
|
|
|
+ protected boolean alwaysCallSingleChoiceCallback;
|
|
protected final int defaultItemColor;
|
|
protected final int defaultItemColor;
|
|
protected ListType listType;
|
|
protected ListType listType;
|
|
protected List<Integer> selectedIndicesList;
|
|
protected List<Integer> selectedIndicesList;
|
|
@@ -202,6 +203,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
|
|
// Determine list type
|
|
// Determine list type
|
|
if (mBuilder.listCallbackSingle != null) {
|
|
if (mBuilder.listCallbackSingle != null) {
|
|
listType = ListType.SINGLE;
|
|
listType = ListType.SINGLE;
|
|
|
|
+ alwaysCallSingleChoiceCallback = builder.alwaysCallSingleChoiceCallback;
|
|
} else if (mBuilder.listCallbackMulti != null) {
|
|
} else if (mBuilder.listCallbackMulti != null) {
|
|
listType = ListType.MULTI;
|
|
listType = ListType.MULTI;
|
|
if (mBuilder.selectedIndices != null) {
|
|
if (mBuilder.selectedIndices != null) {
|
|
@@ -787,6 +789,8 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
|
|
if (mBuilder.autoDismiss && mBuilder.positiveText == null) {
|
|
if (mBuilder.autoDismiss && mBuilder.positiveText == null) {
|
|
dismiss();
|
|
dismiss();
|
|
sendSingleChoiceCallback(v);
|
|
sendSingleChoiceCallback(v);
|
|
|
|
+ } else if (alwaysCallSingleChoiceCallback) {
|
|
|
|
+ sendSingleChoiceCallback(v);
|
|
}
|
|
}
|
|
} else if (mBuilder.listCallbackMulti != null) {
|
|
} else if (mBuilder.listCallbackMulti != null) {
|
|
CheckBox cb = (CheckBox) ((LinearLayout) v).getChildAt(0);
|
|
CheckBox cb = (CheckBox) ((LinearLayout) v).getChildAt(0);
|
|
@@ -825,6 +829,7 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
|
|
protected ListCallback listCallbackSingle;
|
|
protected ListCallback listCallbackSingle;
|
|
protected ListCallbackMulti listCallbackMulti;
|
|
protected ListCallbackMulti listCallbackMulti;
|
|
protected boolean alwaysCallMultiChoiceCallback = false;
|
|
protected boolean alwaysCallMultiChoiceCallback = false;
|
|
|
|
+ protected boolean alwaysCallSingleChoiceCallback = false;
|
|
protected Theme theme = Theme.LIGHT;
|
|
protected Theme theme = Theme.LIGHT;
|
|
protected boolean cancelable = true;
|
|
protected boolean cancelable = true;
|
|
protected float contentLineSpacingMultiplier = 1.3f;
|
|
protected float contentLineSpacingMultiplier = 1.3f;
|
|
@@ -1019,6 +1024,18 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * By default, the single choice callback is only called when the user clicks the positive button
|
|
|
|
+ * or if there are no buttons. Call this to force it to always call on item clicks even if the
|
|
|
|
+ * positive button exists.
|
|
|
|
+ *
|
|
|
|
+ * @return The Builder instance so you can chain calls to it.
|
|
|
|
+ */
|
|
|
|
+ public Builder alwaysCallSingleChoiceCallback() {
|
|
|
|
+ this.alwaysCallSingleChoiceCallback = true;
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Pass null for the selected indices to leave all options unselected initially. Otherwise pass
|
|
* Pass null for the selected indices to leave all options unselected initially. Otherwise pass
|
|
* an array of indices that will be selected initially.
|
|
* an array of indices that will be selected initially.
|