Commit a8ed63c9 authored by Edward Wang's avatar Edward Wang

CommonDialogs: add confirmDialog

parent dec3d729
...@@ -67,19 +67,28 @@ public class CommonDialogs { ...@@ -67,19 +67,28 @@ public class CommonDialogs {
} }
final File fileMedia = new File(adressMediaUri); final File fileMedia = new File(adressMediaUri);
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)
runnable.run();
}
});
}
public static AlertDialog confirmDialog(final Context context,
final String confirmationString,
final DialogInterface.OnClickListener callback) {
AlertDialog alertDialog = new AlertDialog.Builder(context) AlertDialog alertDialog = new AlertDialog.Builder(context)
.setTitle(R.string.validation) .setTitle(R.string.validation).setMessage(confirmationString)
.setMessage(context.getResources().getString(R.string.confirm_delete, fileMedia.getName())) .setIcon(android.R.drawable.ic_dialog_alert)
.setIcon(android.R.drawable.ic_dialog_alert) .setPositiveButton(android.R.string.yes, callback)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { .setNegativeButton(android.R.string.cancel, null).create();
@Override
public void onClick(DialogInterface dialog, int whichButton) {
fileMedia.delete();
if(runnable != null)
runnable.run();
}
})
.setNegativeButton(android.R.string.cancel, null).create();
return alertDialog; 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