Commit a8ed63c9 authored by Edward Wang's avatar Edward Wang

CommonDialogs: add confirmDialog

parent dec3d729
......@@ -67,18 +67,27 @@ public class CommonDialogs {
}
final File fileMedia = new File(adressMediaUri);
AlertDialog alertDialog = new AlertDialog.Builder(context)
.setTitle(R.string.validation)
.setMessage(context.getResources().getString(R.string.confirm_delete, fileMedia.getName()))
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
return confirmDialog(
context,
context.getResources().getString(R.string.confirm_delete,
fileMedia.getName()),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
fileMedia.delete();
if(runnable != null)
if (runnable != null)
runnable.run();
}
})
});
}
public static AlertDialog confirmDialog(final Context context,
final String confirmationString,
final DialogInterface.OnClickListener callback) {
AlertDialog alertDialog = new AlertDialog.Builder(context)
.setTitle(R.string.validation).setMessage(confirmationString)
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(android.R.string.yes, callback)
.setNegativeButton(android.R.string.cancel, null).create();
return alertDialog;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment