Confirm mark as played/unplayed

This commit is contained in:
ByteHamster 2022-05-08 11:46:21 +02:00
parent 934e2802f8
commit 850529856a
2 changed files with 43 additions and 19 deletions

View File

@ -232,31 +232,53 @@ public abstract class EpisodesListFragment extends Fragment implements EpisodeIt
} }
}); });
speedDialView.setOnActionSelectedListener(actionItem -> { speedDialView.setOnActionSelectedListener(actionItem -> {
EpisodeMultiSelectActionHandler handler = int confirmationString = 0;
new EpisodeMultiSelectActionHandler(((MainActivity) getActivity()), actionItem.getId()); if (listAdapter.getSelectedItems().size() >= 25 || listAdapter.shouldSelectLazyLoadedItems()) {
Completable.fromAction( // Should ask for confirmation
() -> { if (actionItem.getId() == R.id.mark_read_batch) {
handler.handleAction(listAdapter.getSelectedItems()); confirmationString = R.string.multi_select_mark_played_confirmation;
if (listAdapter.shouldSelectLazyLoadedItems()) { } else if (actionItem.getId() == R.id.mark_unread_batch) {
int applyPage = page + 1; confirmationString = R.string.multi_select_mark_unplayed_confirmation;
List<FeedItem> nextPage; }
do { }
nextPage = loadMoreData(applyPage); if (confirmationString == 0) {
handler.handleAction(nextPage); performMultiSelectAction(actionItem.getId());
applyPage++; } else {
} while (nextPage.size() == EPISODES_PER_PAGE); new ConfirmationDialog(getActivity(), R.string.multi_select, confirmationString) {
} @Override
}) public void onConfirmButtonPressed(DialogInterface dialog) {
.subscribeOn(Schedulers.io()) performMultiSelectAction(actionItem.getId());
.observeOn(AndroidSchedulers.mainThread()) }
.subscribe(() -> listAdapter.endSelectMode(), }.createNewDialog().show();
error -> Log.e(TAG, Log.getStackTraceString(error))); }
return true; return true;
}); });
return root; 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() { private void setupLoadMoreScrollListener() {
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override @Override

View File

@ -155,6 +155,8 @@
<string name="remove_all_inbox_label">Remove all from inbox</string> <string name="remove_all_inbox_label">Remove all from inbox</string>
<string name="removed_all_inbox_msg">Removed 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="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_info_label">Show information</string>
<string name="show_feed_settings_label">Show podcast settings</string> <string name="show_feed_settings_label">Show podcast settings</string>
<string name="feed_settings_label">Podcast settings</string> <string name="feed_settings_label">Podcast settings</string>