Last active
August 8, 2016 03:40
-
-
Save guptasanchit90/dab4bd5850bc2aafc002 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.AlertDialog; | |
import android.content.Context; | |
import android.content.DialogInterface; | |
/** | |
* Dialog helper class | |
*/ | |
public class DestructiveDialog { | |
public DestructiveDialog(Context context, String title, String message, String positive, String negative, final DialogListener dialogListener) { | |
AlertDialog alertDialog = new AlertDialog.Builder( | |
context) | |
.setPositiveButton(positive, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialogInterface, int i) { | |
if (dialogListener != null) { | |
dialogListener.onDialogEvent(true); | |
} | |
} | |
}) | |
.setNegativeButton(negative, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialogInterface, int i) { | |
if (dialogListener != null) { | |
dialogListener.onDialogEvent(false); | |
} | |
} | |
}) | |
.setTitle(title) | |
.setMessage(message) | |
.create(); | |
alertDialog.show(); | |
} | |
public interface DialogListener { | |
void onDialogEvent(boolean action); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment