From f7a0ef47fe3dead66452b8c6c8eb9f08e6e856fb Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Thu, 7 Mar 2019 18:23:54 +0100 Subject: [PATCH] Add confirmation dialog for feed deletion --- .../app/activities/ManageFeedsActivity.java | 52 +++++++++---------- app/src/main/res/values-fr-rFR/strings.xml | 2 + app/src/main/res/values/strings.xml | 2 + 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/com/readrops/app/activities/ManageFeedsActivity.java b/app/src/main/java/com/readrops/app/activities/ManageFeedsActivity.java index 4951125b..d5d70ec4 100644 --- a/app/src/main/java/com/readrops/app/activities/ManageFeedsActivity.java +++ b/app/src/main/java/com/readrops/app/activities/ManageFeedsActivity.java @@ -56,20 +56,7 @@ public class ManageFeedsActivity extends AppCompatActivity { @Override public void onDelete(FeedWithFolder feedWithFolder) { - viewModel.deleteFeed(feedWithFolder.getFeed().getId()) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new DisposableCompletableObserver() { - @Override - public void onComplete() { - Toast.makeText(getApplication(), "feed deleted", Toast.LENGTH_LONG).show(); - } - - @Override - public void onError(Throwable e) { - Toast.makeText(getApplication(), "error on feed deletion", Toast.LENGTH_LONG).show(); - } - }); + deleteFolder(feedWithFolder.getFeed().getId()); } }); @@ -93,20 +80,7 @@ public class ManageFeedsActivity extends AppCompatActivity { @Override public void onDelete(FeedWithFolder feedWithFolder) { - viewModel.deleteFeed(feedWithFolder.getFeed().getId()) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new DisposableCompletableObserver() { - @Override - public void onComplete() { - Toast.makeText(getApplication(), "feed deleted", Toast.LENGTH_LONG).show(); - } - - @Override - public void onError(Throwable e) { - Toast.makeText(getApplication(), "error on feed deletion", Toast.LENGTH_LONG).show(); - } - }); + deleteFolder(feedWithFolder.getFeed().getId()); } }); @@ -153,6 +127,28 @@ public class ManageFeedsActivity extends AppCompatActivity { }); } + private void deleteFolder(int feedId) { + new MaterialDialog.Builder(this) + .title(getString(R.string.delete_feed)) + .positiveText(getString(R.string.validate)) + .negativeText(getString(R.string.cancel)) + .onPositive((dialog, which) -> viewModel.deleteFeed(feedId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new DisposableCompletableObserver() { + @Override + public void onComplete() { + Toast.makeText(getApplication(), "feed deleted", Toast.LENGTH_LONG).show(); + } + + @Override + public void onError(Throwable e) { + Toast.makeText(getApplication(), "error on feed deletion", Toast.LENGTH_LONG).show(); + } + })) + .show(); + } + private void openEditFeedDialog(FeedWithFolder feedWithFolder) { EditFeedDialog editFeedDialog = new EditFeedDialog(); diff --git a/app/src/main/res/values-fr-rFR/strings.xml b/app/src/main/res/values-fr-rFR/strings.xml index 847f05c2..13cef318 100644 --- a/app/src/main/res/values-fr-rFR/strings.xml +++ b/app/src/main/res/values-fr-rFR/strings.xml @@ -28,5 +28,7 @@ Modifier le flux Dossier Pas de dossier + Retour + Supprimer le flux ? \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ff6ba7ed..ed18e0d6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -30,4 +30,6 @@ Edit feed Folder No folder + Cancel + Delete feed ?