Created
October 28, 2017 08:21
-
-
Save rezaiyan/88a0fce6c4c270c57b347ff2a38407d6 to your computer and use it in GitHub Desktop.
This is AlertDialogBuilder with abstaction that can decrease boilerplate
This file contains hidden or 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
public abstract class AlertBuilder { | |
public abstract void ok(); | |
public AlertDialog.Builder create(Context context, String message) { | |
final AlertDialog.Builder builder; | |
builder = new AlertDialog.Builder(context); | |
builder.setMessage(message) | |
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int which) { | |
AlertBuilder.this.ok(); | |
} | |
}) | |
.setNegativeButton(android.R.string.no, null); | |
return builder; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment