Add base code for AlertDialog

This commit is contained in:
misaochan 2016-12-15 15:15:13 +13:00
parent 8990f79059
commit bb41565b78

View file

@ -27,7 +27,7 @@ public class ExistingFileAsync extends AsyncTask<Void, Void, Boolean> {
private String fileSHA1; private String fileSHA1;
private Context context; private Context context;
private AlertDialog alertDialog; private AlertDialog.Builder alertDialog;
public ExistingFileAsync(String fileSHA1, Context context) { public ExistingFileAsync(String fileSHA1, Context context) {
super(); super();
@ -38,7 +38,7 @@ public class ExistingFileAsync extends AsyncTask<Void, Void, Boolean> {
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
super.onPreExecute(); super.onPreExecute();
alertDialog = new AlertDialog.Builder(ExistingFileAsync.this); alertDialog = new AlertDialog.Builder(context);
} }
@Override @Override
@ -78,26 +78,14 @@ public class ExistingFileAsync extends AsyncTask<Void, Void, Boolean> {
super.onPostExecute(fileExists); super.onPostExecute(fileExists);
//TODO: Add Dialog here to tell user file exists, do you want to continue? Yes/No //TODO: Add Dialog here to tell user file exists, do you want to continue? Yes/No
alertDialog.setTitle("The Process"); alertDialog.setMessage("test");
alertDialog.setIcon(R.drawable.success); alertDialog.setCancelable(false);
alertDialog.setCanceledOnTouchOutside(false); alertDialog.setPositiveButton("ok", new DialogInterface.OnClickListener() {
alertDialog.setMessage("All done!"); public void onClick(DialogInterface dialog, int id) {
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", dialog.cancel();
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent A = new Intent(DownloadActivity.this, Menu_activity.class);
startActivity(A);
finish();
} }
}); });
alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { AlertDialog alertLogin = alertDialog.create();
@Override alertLogin.show();
public void onDismiss(DialogInterface dialog) {
Intent A = new Intent(DownloadActivity.this, Menu_activity.class);
startActivity(A);
finish();
}
});
alertDialog.show();
} }
} }