package de.thedevstack.conversationsplus.ui.dialogs; import android.content.Context; import android.content.DialogInterface; import de.thedevstack.conversationsplus.ui.listeners.SimpleUserDecisionCallback; import eu.siacs.conversations.R; /** * A dialog to give the user the choice to decide whether to do something or not. * A UserDecisionListener is used to provide the functionality to be performed by clicking on yes, or no. */ public class SimpleConfirmDialog extends AbstractAlertDialog { protected final SimpleUserDecisionCallback callback; public SimpleConfirmDialog(Context context, String title, SimpleUserDecisionCallback userDecisionCallback) { super(context, title); this.callback = userDecisionCallback; this.setPositiveButton(R.string.cplus_ok, new ConfirmOnClickListener()); this.setNegativeButton(R.string.cancel, null); } public SimpleConfirmDialog(Context context, int titleTextId, SimpleUserDecisionCallback userDecisionCallback) { super(context, titleTextId); this.callback = userDecisionCallback; this.setPositiveButton(R.string.cplus_ok, new ConfirmOnClickListener()); this.setNegativeButton(R.string.cancel, null); } private class ConfirmOnClickListener implements DialogInterface.OnClickListener { @Override public void onClick(DialogInterface dialog, int which) { callback.onYes(); } } }