mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Add context to constructor, copy AlertDialog code
This commit is contained in:
parent
99af3feaec
commit
8990f79059
2 changed files with 35 additions and 3 deletions
|
|
@ -1,6 +1,8 @@
|
|||
package fr.free.nrw.commons.upload;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
|
|
@ -10,6 +12,8 @@ import org.mediawiki.api.MWApi;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import fr.free.nrw.commons.CommonsApplication;
|
||||
|
||||
/**
|
||||
|
|
@ -19,16 +23,22 @@ import fr.free.nrw.commons.CommonsApplication;
|
|||
public class ExistingFileAsync extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
private static final String TAG = fr.free.nrw.commons.upload.ExistingFileAsync.class.getName();
|
||||
private String fileSHA1;
|
||||
|
||||
public ExistingFileAsync(String fileSHA1) {
|
||||
private String fileSHA1;
|
||||
private Context context;
|
||||
|
||||
private AlertDialog alertDialog;
|
||||
|
||||
public ExistingFileAsync(String fileSHA1, Context context) {
|
||||
super();
|
||||
this.fileSHA1 = fileSHA1;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
alertDialog = new AlertDialog.Builder(ExistingFileAsync.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -67,5 +77,27 @@ public class ExistingFileAsync extends AsyncTask<Void, Void, Boolean> {
|
|||
protected void onPostExecute(Boolean fileExists) {
|
||||
super.onPostExecute(fileExists);
|
||||
//TODO: Add Dialog here to tell user file exists, do you want to continue? Yes/No
|
||||
|
||||
alertDialog.setTitle("The Process");
|
||||
alertDialog.setIcon(R.drawable.success);
|
||||
alertDialog.setCanceledOnTouchOutside(false);
|
||||
alertDialog.setMessage("All done!");
|
||||
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
|
||||
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() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
Intent A = new Intent(DownloadActivity.this, Menu_activity.class);
|
||||
startActivity(A);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
}
|
||||
}
|
||||
|
|
@ -251,7 +251,7 @@ public class ShareActivity
|
|||
|
||||
//FIXME: Replace hardcoded string with call to Commons API instead (use TitleCategories.java as template)
|
||||
|
||||
ExistingFileAsync fileAsyncTask = new ExistingFileAsync(fileSHA1);
|
||||
ExistingFileAsync fileAsyncTask = new ExistingFileAsync(fileSHA1, this);
|
||||
fileAsyncTask.execute();
|
||||
|
||||
} catch (IOException e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue