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 8813f7d35..1b52705b2 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 @@ -87,7 +87,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment debouncedSaveSignal; private CompositeDisposable disposables; - private Disposable removeWatchedWorker; + private Disposable removeWatchedDisposable; /* Has the playlist been fully loaded from db */ private AtomicBoolean isLoadingComplete; @@ -300,12 +300,12 @@ public class LocalPlaylistFragment extends BaseLocalListFragment playlist) -> { List localItems = new ArrayList<>(); @@ -380,36 +380,42 @@ public class LocalPlaylistFragment extends BaseLocalListFragment it_history; - StreamHistoryEntry history_item; Iterator it_playlist = playlist.iterator(); PlaylistStreamEntry playlist_item = null; boolean isNonDuplicate; - while (it_playlist.hasNext()) { + Iterator it_history = recordManager.getStreamHistory().blockingFirst().iterator(); + ArrayList history_streamIds = new ArrayList<>(); + + while(it_history.hasNext()) + { + history_streamIds.add(it_history.next().getStreamId()); + } + + while(it_playlist.hasNext()) + { playlist_item = it_playlist.next(); - - it_history = recordManager.getStreamHistory().blockingFirst().iterator(); - isNonDuplicate = true; - while (it_history.hasNext()) { - history_item = it_history.next(); - if (history_item.streamId == playlist_item.streamId) { + + for (long history_id : history_streamIds) { + if (history_id == playlist_item.getStreamId()) { isNonDuplicate = false; break; } } + if (isNonDuplicate) { localItems.add(playlist_item); } else { removedItemCount++; - if (playlistManager.getPlaylistThumbnail(playlistId).equals(playlist_item.thumbnailUrl)) { + if (!thumbnailVideoRemoved && playlistManager.getPlaylistThumbnail(playlistId).equals(playlist_item.getStreamEntity().getThumbnailUrl())) { thumbnailVideoRemoved = true; } } } + return Flowable.just(localItems, removedItemCount, thumbnailVideoRemoved); } )