Add confirmation dialog for feed deletion

This commit is contained in:
Shinokuni 2019-03-07 18:23:54 +01:00
parent 767139d1ce
commit f7a0ef47fe
3 changed files with 28 additions and 28 deletions

View File

@ -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();

View File

@ -28,5 +28,7 @@
<string name="edit_feed">Modifier le flux</string>
<string name="folder">Dossier</string>
<string name="no_folder">Pas de dossier</string>
<string name="cancel">Retour</string>
<string name="delete_feed">Supprimer le flux ?</string>
</resources>

View File

@ -30,4 +30,6 @@
<string name="edit_feed">Edit feed</string>
<string name="folder">Folder</string>
<string name="no_folder">No folder</string>
<string name="cancel">Cancel</string>
<string name="delete_feed">Delete feed ?</string>
</resources>