Tidy ExistingFileAsync, add documentation

This commit is contained in:
misaochan 2016-12-15 15:28:25 +13:00
parent b5ccc36a77
commit d4c63b7b5f

View file

@ -1,6 +1,5 @@
package fr.free.nrw.commons.upload; package fr.free.nrw.commons.upload;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
@ -20,7 +19,7 @@ import fr.free.nrw.commons.contributions.ContributionsActivity;
/** /**
* Sends asynchronous queries to the Commons MediaWiki API to check that file doesn't already exist * Sends asynchronous queries to the Commons MediaWiki API to check that file doesn't already exist
* Returns true if file exists, false if it doesn't * Displays a warning to the user if the file already exists on Commons
*/ */
public class ExistingFileAsync extends AsyncTask<Void, Void, Boolean> { public class ExistingFileAsync extends AsyncTask<Void, Void, Boolean> {
@ -75,12 +74,11 @@ public class ExistingFileAsync extends AsyncTask<Void, Void, Boolean> {
@Override @Override
protected void onPostExecute(Boolean fileExists) { protected void onPostExecute(Boolean fileExists) {
super.onPostExecute(fileExists); super.onPostExecute(fileExists);
//TODO: Add Dialog here to tell user file exists, do you want to continue? Yes/No
// If file exists, display warning to user.
// Use soft warning for now (user able to choose to proceed) until have determined that implementation works without bugs
if (fileExists) { if (fileExists) {
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage("This file already exists in Commons. Are you sure you want to proceed?") builder.setMessage("This file already exists in Commons. Are you sure you want to proceed?")
.setTitle("Warning"); .setTitle("Warning");
builder.setPositiveButton("No", new DialogInterface.OnClickListener() { builder.setPositiveButton("No", new DialogInterface.OnClickListener() {
@ -89,7 +87,6 @@ public class ExistingFileAsync extends AsyncTask<Void, Void, Boolean> {
Intent intent = new Intent(context, ContributionsActivity.class); Intent intent = new Intent(context, ContributionsActivity.class);
context.startActivity(intent); context.startActivity(intent);
} }
}); });
builder.setNegativeButton("Yes", new DialogInterface.OnClickListener() { builder.setNegativeButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {