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 -> {
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

View File

@ -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>