From b5ccc36a77cf8973725714dc95ceb42fc4747dc6 Mon Sep 17 00:00:00 2001 From: misaochan Date: Thu, 15 Dec 2016 15:24:01 +1300 Subject: [PATCH] Add 'if' check for file exists --- .../nrw/commons/upload/ExistingFileAsync.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/upload/ExistingFileAsync.java b/app/src/main/java/fr/free/nrw/commons/upload/ExistingFileAsync.java index 257eb53d4..95f5659c7 100644 --- a/app/src/main/java/fr/free/nrw/commons/upload/ExistingFileAsync.java +++ b/app/src/main/java/fr/free/nrw/commons/upload/ExistingFileAsync.java @@ -77,25 +77,28 @@ public class ExistingFileAsync extends AsyncTask { super.onPostExecute(fileExists); //TODO: Add Dialog here to tell user file exists, do you want to continue? Yes/No - AlertDialog.Builder builder = new AlertDialog.Builder(context); + if (fileExists) { - builder.setMessage("This file already exists in Commons. Are you sure you want to proceed?") - .setTitle("Warning"); - builder.setPositiveButton("No", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - //Go back to ContributionsActivity - Intent intent = new Intent(context, ContributionsActivity.class); - context.startActivity(intent); - } + AlertDialog.Builder builder = new AlertDialog.Builder(context); - }); - builder.setNegativeButton("Yes", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - //No need to do anything, user remains on upload screen - } - }); + builder.setMessage("This file already exists in Commons. Are you sure you want to proceed?") + .setTitle("Warning"); + builder.setPositiveButton("No", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + //Go back to ContributionsActivity + Intent intent = new Intent(context, ContributionsActivity.class); + context.startActivity(intent); + } - AlertDialog dialog = builder.create(); - dialog.show(); + }); + builder.setNegativeButton("Yes", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + //No need to do anything, user remains on upload screen + } + }); + + AlertDialog dialog = builder.create(); + dialog.show(); + } } } \ No newline at end of file