summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2022-05-08 11:46:21 +0200
committerByteHamster <info@bytehamster.com>2022-05-08 21:28:59 +0200
commit850529856a0dfdab701b6720f35f15ee13a090c2 (patch)
tree6a2ef8321725d65045f1883c59380849c70fb825
parent934e2802f8a6f9552489726ef1a43f1476eda233 (diff)
downloadAntennaPod-850529856a0dfdab701b6720f35f15ee13a090c2.zip
Confirm mark as played/unplayed
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java60
-rw-r--r--ui/i18n/src/main/res/values/strings.xml2
2 files changed, 43 insertions, 19 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java
index 0f75c2fb7..03dbc6ae4 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java
@@ -232,31 +232,53 @@ public abstract class EpisodesListFragment extends Fragment implements EpisodeIt
}
});
speedDialView.setOnActionSelectedListener(actionItem -> {
- EpisodeMultiSelectActionHandler handler =
- new EpisodeMultiSelectActionHandler(((MainActivity) getActivity()), actionItem.getId());
- Completable.fromAction(
- () -> {
- handler.handleAction(listAdapter.getSelectedItems());
- if (listAdapter.shouldSelectLazyLoadedItems()) {
- int applyPage = page + 1;
- List<FeedItem> nextPage;
- do {
- nextPage = loadMoreData(applyPage);
- handler.handleAction(nextPage);
- applyPage++;
- } while (nextPage.size() == EPISODES_PER_PAGE);
- }
- })
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(() -> listAdapter.endSelectMode(),
- error -> Log.e(TAG, Log.getStackTraceString(error)));
+ int confirmationString = 0;
+ if (listAdapter.getSelectedItems().size() >= 25 || listAdapter.shouldSelectLazyLoadedItems()) {
+ // Should ask for confirmation
+ if (actionItem.getId() == R.id.mark_read_batch) {
+ confirmationString = R.string.multi_select_mark_played_confirmation;
+ } else if (actionItem.getId() == R.id.mark_unread_batch) {
+ confirmationString = R.string.multi_select_mark_unplayed_confirmation;
+ }
+ }
+ if (confirmationString == 0) {
+ performMultiSelectAction(actionItem.getId());
+ } else {
+ new ConfirmationDialog(getActivity(), R.string.multi_select, confirmationString) {
+ @Override
+ public void onConfirmButtonPressed(DialogInterface dialog) {
+ performMultiSelectAction(actionItem.getId());
+ }
+ }.createNewDialog().show();
+ }
return true;
});
return root;
}
+ private void performMultiSelectAction(int actionItemId) {
+ EpisodeMultiSelectActionHandler handler =
+ new EpisodeMultiSelectActionHandler(((MainActivity) getActivity()), actionItemId);
+ Completable.fromAction(
+ () -> {
+ handler.handleAction(listAdapter.getSelectedItems());
+ if (listAdapter.shouldSelectLazyLoadedItems()) {
+ int applyPage = page + 1;
+ List<FeedItem> nextPage;
+ do {
+ nextPage = loadMoreData(applyPage);
+ handler.handleAction(nextPage);
+ applyPage++;
+ } while (nextPage.size() == EPISODES_PER_PAGE);
+ }
+ })
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(() -> listAdapter.endSelectMode(),
+ error -> Log.e(TAG, Log.getStackTraceString(error)));
+ }
+
private void setupLoadMoreScrollListener() {
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml
index 836c418a9..8c8dd1b2f 100644
--- a/ui/i18n/src/main/res/values/strings.xml
+++ b/ui/i18n/src/main/res/values/strings.xml
@@ -155,6 +155,8 @@
<string name="remove_all_inbox_label">Remove all from inbox</string>
<string name="removed_all_inbox_msg">Removed all from inbox</string>
<string name="remove_all_inbox_confirmation_msg">Please confirm that you want to remove all from the inbox.</string>
+ <string name="multi_select_mark_played_confirmation">Please confirm that you want to mark all selected items as played.</string>
+ <string name="multi_select_mark_unplayed_confirmation">Please confirm that you want to mark all selected items as unplayed.</string>
<string name="show_info_label">Show information</string>
<string name="show_feed_settings_label">Show podcast settings</string>
<string name="feed_settings_label">Podcast settings</string>