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 c68cd2f55..315056f6c 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 @@ -2,7 +2,6 @@ package org.schabi.newpipe.local.playlist; import android.app.Activity; import android.content.Context; -import android.os.AsyncTask; import android.os.Bundle; import android.os.Parcelable; import android.text.TextUtils; @@ -56,6 +55,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposables; +import io.reactivex.schedulers.Schedulers; import io.reactivex.subjects.PublishSubject; import static org.schabi.newpipe.util.AnimationUtils.animateView; @@ -79,7 +79,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment debouncedSaveSignal; private CompositeDisposable disposables; + private Disposable removeWatchedWorker; /* Has the playlist been fully loaded from db */ private AtomicBoolean isLoadingComplete; @@ -151,7 +152,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment playlist) -> { + remover.doInBackground(playlist); + return true; + } + ).observeOn(AndroidSchedulers.mainThread()) + .subscribe(playlist -> { + remover.onPostExecute(); + }, (@io.reactivex.annotations.NonNull Throwable throwable) -> { + onError(throwable); + }); break; default: return super.onOptionsItemSelected(item); @@ -716,27 +732,24 @@ public class LocalPlaylistFragment extends BaseLocalListFragment { + private class RemoveWatchedStreams{ List localItems = new ArrayList<>(); Long RemovedItemCount = 0l; boolean thumbnailVideoRemoved = false; - @Override + // Do this in the main thread protected void onPreExecute() { - super.onPreExecute(); showLoading(); - localItems.clear(); } - @Override - protected Long doInBackground(String... urls) { + // Do not do this in the main thread + protected Long doInBackground(List playlist) { HistoryRecordManager recordManager = new HistoryRecordManager(getContext()); Iterator it_history; StreamHistoryEntry history_item; - Flowable> playlist = playlistManager.getPlaylistStreams(playlistId); - Iterator it_playlist = playlist.blockingFirst().iterator(); + Iterator it_playlist = playlist.iterator(); PlaylistStreamEntry playlist_item = null; boolean isNonDuplicate; @@ -769,8 +782,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/local_playlist_header.xml b/app/src/main/res/layout/local_playlist_header.xml index 372187a64..04fe32ab0 100644 --- a/app/src/main/res/layout/local_playlist_header.xml +++ b/app/src/main/res/layout/local_playlist_header.xml @@ -50,7 +50,7 @@ android:layout_height="wrap_content" android:layout_below="@id/playlist_stream_count"> - + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 770d3d4e8..e0591e7fd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -593,6 +593,7 @@ Choose an instance App language System default + Remove watched Due to ExoPlayer constraints the seek duration was set to %d seconds @@ -637,6 +638,4 @@ Enable fast mode Disable fast mode Do you think feed loading is too slow? If so, try enabling fast loading (you can change it in settings or by pressing the button below).\n\nNewPipe offers two feed loading strategies:\n• Fetching the whole subscription channel, which is slow but complete.\n• Using a dedicated service endpoint, which is fast but usually not complete.\n\nThe difference between the two is that the fast one usually lacks some information, like the item\'s duration or type (can\'t distinguish between live videos and normal ones) and it may return less items.\n\nYouTube is an example of a service that offers this fast method with its RSS feed.\n\nSo the choice boils down to what you prefer: speed or precise information. - - Remove Watched