|
|
@@ -25,37 +25,58 @@ import kr.co.zumo.app.lifeplus.view.Event;
|
|
|
public class ConfirmDialog extends TextDialog {
|
|
|
|
|
|
@StringRes
|
|
|
- protected int buttonLabel = R.string.empty_string;
|
|
|
+ protected int positiveButtonLabel = R.string.empty_string;
|
|
|
+ @StringRes
|
|
|
+ protected int negativeButtonLabel = R.string.empty_string;
|
|
|
|
|
|
/**
|
|
|
- * 표시할 buttonLabel 지정
|
|
|
+ * 표시할 positiveButtonLabel 지정
|
|
|
*
|
|
|
* @param stringId
|
|
|
*/
|
|
|
- public void setButtonLabelId(@StringRes int stringId) {
|
|
|
- this.buttonLabel = stringId;
|
|
|
+ public void setPositiveButtonLabelId(@StringRes int stringId) {
|
|
|
+ this.positiveButtonLabel = stringId;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setNegativeButtonLabelId(@StringRes int stringId) {
|
|
|
+ this.negativeButtonLabel = stringId;
|
|
|
}
|
|
|
|
|
|
@NonNull
|
|
|
@Override
|
|
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
|
- if (buttonLabel == R.string.empty_string) {
|
|
|
- buttonLabel = R.string.confirm;
|
|
|
+ if (positiveButtonLabel == R.string.empty_string) {
|
|
|
+ positiveButtonLabel = R.string.confirm;
|
|
|
}
|
|
|
+
|
|
|
+ if (negativeButtonLabel == R.string.empty_string) {
|
|
|
+ negativeButtonLabel = R.string.cancel;
|
|
|
+ }
|
|
|
+
|
|
|
// Use the Builder class for convenient dialog construction
|
|
|
android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(getActivity());
|
|
|
builder.setMessage(text)
|
|
|
- .setPositiveButton(buttonLabel, new DialogInterface.OnClickListener() {
|
|
|
+ .setPositiveButton(positiveButtonLabel, new DialogInterface.OnClickListener() {
|
|
|
public void onClick(DialogInterface dialog, int id) {
|
|
|
if (null != getCustomListener()) {
|
|
|
- getCustomListener().onDialogResult(ConfirmDialog.this, new Event.Builder(Event.CONFIRM).build());
|
|
|
+ if (positiveButtonLabel == R.string.go_execute) {
|
|
|
+ getCustomListener().onDialogCanceled(ConfirmDialog.this);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ getCustomListener().onDialogResult(ConfirmDialog.this, new Event.Builder(Event.CONFIRM).build());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
|
|
+ .setNegativeButton(negativeButtonLabel, new DialogInterface.OnClickListener() {
|
|
|
public void onClick(DialogInterface dialog, int id) {
|
|
|
if (null != getCustomListener()) {
|
|
|
- getCustomListener().onDialogCanceled(ConfirmDialog.this);
|
|
|
+ if (negativeButtonLabel == R.string.back) {
|
|
|
+ getCustomListener().onDialogResult(ConfirmDialog.this, new Event.Builder(Event.CONFIRM).build());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ getCustomListener().onDialogCanceled(ConfirmDialog.this);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|