From 437b86d1a7cfe362172ef9522aa2bafd8d91d698 Mon Sep 17 00:00:00 2001 From: Stypox Date: Thu, 23 Apr 2020 23:34:24 +0200 Subject: [PATCH] Use centralized CompositeDisposable instead of custom Disposable Also do not show any dialog if the user is aready removing watched videos in a local playlist --- .../local/playlist/LocalPlaylistFragment.java | 49 ++++++++----------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java index 3ec9ae216..485d3f391 100644 --- a/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java @@ -89,12 +89,13 @@ public class LocalPlaylistFragment extends BaseLocalListFragment debouncedSaveSignal; private CompositeDisposable disposables; - private Disposable removeWatchedDisposable; /* Has the playlist been fully loaded from db */ private AtomicBoolean isLoadingComplete; /* Has the playlist been modified (e.g. items reordered or deleted) */ private AtomicBoolean isModified; + /* Is the playlist currently being processed to remove watched videos */ + private boolean isRemovingWatched = false; public static LocalPlaylistFragment getInstance(final long playlistId, final String name) { LocalPlaylistFragment instance = new LocalPlaylistFragment(); @@ -304,14 +305,9 @@ public class LocalPlaylistFragment extends BaseLocalListFragment removeWatchedStreams(false)) - .setNeutralButton( - R.string.remove_watched_popup_yes_and_partially_watched_videos, - (DialogInterface d, int id) -> removeWatchedStreams(true)) - .setNegativeButton(R.string.cancel, - (DialogInterface d, int id) -> d.cancel()) - .create() - .show(); + if (!isRemovingWatched) { + new AlertDialog.Builder(requireContext()) + .setMessage(R.string.remove_watched_popup_warning) + .setTitle(R.string.remove_watched_popup_title) + .setPositiveButton(R.string.yes, + (DialogInterface d, int id) -> removeWatchedStreams(false)) + .setNeutralButton( + R.string.remove_watched_popup_yes_and_partially_watched_videos, + (DialogInterface d, int id) -> removeWatchedStreams(true)) + .setNegativeButton(R.string.cancel, + (DialogInterface d, int id) -> d.cancel()) + .create() + .show(); + } break; default: return super.onOptionsItemSelected(item); @@ -382,13 +380,13 @@ public class LocalPlaylistFragment extends BaseLocalListFragment playlist) -> { // Playlist data @@ -468,13 +466,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment