|
@@ -10,14 +10,14 @@ import android.support.annotation.StringRes;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Convenience class for migrating old dialogs code
|
|
|
|
- * Not all methods are implemented yet
|
|
|
|
- *
|
|
|
|
- * @deprecated
|
|
|
|
|
|
+ * Convenience class for migrating old dialogs code. Not all methods are implemented yet.
|
|
*
|
|
*
|
|
|
|
+ * @deprecated Using MaterialDialog.Builder directly is recommended.
|
|
*/
|
|
*/
|
|
public class MaterialDialogCompat {
|
|
public class MaterialDialogCompat {
|
|
|
|
+
|
|
public static class Builder {
|
|
public static class Builder {
|
|
|
|
+
|
|
private MaterialDialog.Builder builder;
|
|
private MaterialDialog.Builder builder;
|
|
|
|
|
|
private DialogInterface.OnClickListener negativeDialogListener;
|
|
private DialogInterface.OnClickListener negativeDialogListener;
|
|
@@ -95,91 +95,85 @@ public class MaterialDialogCompat {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set a listener to be invoked when the negative button of the dialog is pressed.
|
|
* Set a listener to be invoked when the negative button of the dialog is pressed.
|
|
- * @param textId The resource id of the text to display in the negative button
|
|
|
|
- * @param listener The {@link DialogInterface.OnClickListener} to use.
|
|
|
|
*
|
|
*
|
|
|
|
+ * @param textId The resource id of the text to display in the negative button
|
|
|
|
+ * @param listener The {@link DialogInterface.OnClickListener} to use.
|
|
* @return This Builder object to allow for chaining of calls to set methods
|
|
* @return This Builder object to allow for chaining of calls to set methods
|
|
*/
|
|
*/
|
|
public Builder setNegativeButton(@StringRes int textId,
|
|
public Builder setNegativeButton(@StringRes int textId,
|
|
DialogInterface.OnClickListener listener) {
|
|
DialogInterface.OnClickListener listener) {
|
|
builder.negativeText(textId);
|
|
builder.negativeText(textId);
|
|
negativeDialogListener = listener;
|
|
negativeDialogListener = listener;
|
|
-
|
|
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set a listener to be invoked when the negative button of the dialog is pressed.
|
|
* Set a listener to be invoked when the negative button of the dialog is pressed.
|
|
- * @param text The text to display in the negative button
|
|
|
|
- * @param listener The {@link DialogInterface.OnClickListener} to use.
|
|
|
|
*
|
|
*
|
|
|
|
+ * @param text The text to display in the negative button
|
|
|
|
+ * @param listener The {@link DialogInterface.OnClickListener} to use.
|
|
* @return This Builder object to allow for chaining of calls to set methods
|
|
* @return This Builder object to allow for chaining of calls to set methods
|
|
*/
|
|
*/
|
|
public Builder setNegativeButton(CharSequence text,
|
|
public Builder setNegativeButton(CharSequence text,
|
|
DialogInterface.OnClickListener listener) {
|
|
DialogInterface.OnClickListener listener) {
|
|
builder.negativeText(text);
|
|
builder.negativeText(text);
|
|
negativeDialogListener = listener;
|
|
negativeDialogListener = listener;
|
|
-
|
|
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set a listener to be invoked when the positive button of the dialog is pressed.
|
|
* Set a listener to be invoked when the positive button of the dialog is pressed.
|
|
- * @param textId The resource id of the text to display in the positive button
|
|
|
|
- * @param listener The {@link DialogInterface.OnClickListener} to use.
|
|
|
|
*
|
|
*
|
|
|
|
+ * @param textId The resource id of the text to display in the positive button
|
|
|
|
+ * @param listener The {@link DialogInterface.OnClickListener} to use.
|
|
* @return This Builder object to allow for chaining of calls to set methods
|
|
* @return This Builder object to allow for chaining of calls to set methods
|
|
*/
|
|
*/
|
|
public Builder setPositiveButton(@StringRes int textId,
|
|
public Builder setPositiveButton(@StringRes int textId,
|
|
DialogInterface.OnClickListener listener) {
|
|
DialogInterface.OnClickListener listener) {
|
|
builder.positiveText(textId);
|
|
builder.positiveText(textId);
|
|
positiveDialogListener = listener;
|
|
positiveDialogListener = listener;
|
|
-
|
|
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set a listener to be invoked when the positive button of the dialog is pressed.
|
|
* Set a listener to be invoked when the positive button of the dialog is pressed.
|
|
- * @param text The text to display in the positive button
|
|
|
|
- * @param listener The {@link DialogInterface.OnClickListener} to use.
|
|
|
|
*
|
|
*
|
|
|
|
+ * @param text The text to display in the positive button
|
|
|
|
+ * @param listener The {@link DialogInterface.OnClickListener} to use.
|
|
* @return This Builder object to allow for chaining of calls to set methods
|
|
* @return This Builder object to allow for chaining of calls to set methods
|
|
*/
|
|
*/
|
|
public Builder setPositiveButton(CharSequence text,
|
|
public Builder setPositiveButton(CharSequence text,
|
|
DialogInterface.OnClickListener listener) {
|
|
DialogInterface.OnClickListener listener) {
|
|
builder.positiveText(text);
|
|
builder.positiveText(text);
|
|
positiveDialogListener = listener;
|
|
positiveDialogListener = listener;
|
|
-
|
|
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set a listener to be invoked when the neutral button of the dialog is pressed.
|
|
* Set a listener to be invoked when the neutral button of the dialog is pressed.
|
|
- * @param textId The resource id of the text to display in the neutral button
|
|
|
|
- * @param listener The {@link DialogInterface.OnClickListener} to use.
|
|
|
|
*
|
|
*
|
|
|
|
+ * @param textId The resource id of the text to display in the neutral button
|
|
|
|
+ * @param listener The {@link DialogInterface.OnClickListener} to use.
|
|
* @return This Builder object to allow for chaining of calls to set methods
|
|
* @return This Builder object to allow for chaining of calls to set methods
|
|
*/
|
|
*/
|
|
public Builder setNeutralButton(@StringRes int textId,
|
|
public Builder setNeutralButton(@StringRes int textId,
|
|
DialogInterface.OnClickListener listener) {
|
|
DialogInterface.OnClickListener listener) {
|
|
builder.neutralText(textId);
|
|
builder.neutralText(textId);
|
|
neutralDialogListener = listener;
|
|
neutralDialogListener = listener;
|
|
-
|
|
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* Set a listener to be invoked when the neutral button of the dialog is pressed.
|
|
* Set a listener to be invoked when the neutral button of the dialog is pressed.
|
|
- * @param text The text to display in the neutral button
|
|
|
|
- * @param listener The {@link DialogInterface.OnClickListener} to use.
|
|
|
|
*
|
|
*
|
|
|
|
+ * @param text The text to display in the neutral button
|
|
|
|
+ * @param listener The {@link DialogInterface.OnClickListener} to use.
|
|
* @return This Builder object to allow for chaining of calls to set methods
|
|
* @return This Builder object to allow for chaining of calls to set methods
|
|
*/
|
|
*/
|
|
public Builder setNeutralButton(CharSequence text,
|
|
public Builder setNeutralButton(CharSequence text,
|
|
DialogInterface.OnClickListener listener) {
|
|
DialogInterface.OnClickListener listener) {
|
|
builder.neutralText(text);
|
|
builder.neutralText(text);
|
|
neutralDialogListener = listener;
|
|
neutralDialogListener = listener;
|
|
-
|
|
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -213,9 +207,7 @@ public class MaterialDialogCompat {
|
|
*/
|
|
*/
|
|
public Builder setItems(CharSequence[] items, DialogInterface.OnClickListener listener) {
|
|
public Builder setItems(CharSequence[] items, DialogInterface.OnClickListener listener) {
|
|
builder.items(items);
|
|
builder.items(items);
|
|
-
|
|
|
|
onClickListener = listener;
|
|
onClickListener = listener;
|
|
-
|
|
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -228,7 +220,6 @@ public class MaterialDialogCompat {
|
|
public AlertDialog create() {
|
|
public AlertDialog create() {
|
|
addButtonsCallback();
|
|
addButtonsCallback();
|
|
addItemsCallBack();
|
|
addItemsCallBack();
|
|
-
|
|
|
|
return builder.build();
|
|
return builder.build();
|
|
}
|
|
}
|
|
|
|
|