From 8ea98b64aa81ac15f3d01e2764be38b50220644e Mon Sep 17 00:00:00 2001 From: LingYinTianMeng <2632252014@qq.com> Date: Sun, 17 Apr 2022 22:23:03 +0800 Subject: [PATCH 1/4] fix issue #7563 --- .../local/playlist/LocalPlaylistFragment.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 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 0eb56d7169c..7cd2a3ec169 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 @@ -414,14 +414,21 @@ public void removeWatchedStreams(final boolean removePartiallyWatched) { } else { final Iterator streamStatesIter = recordManager .loadLocalStreamStateBatch(playlist).blockingGet().iterator(); - while (playlistIter.hasNext()) { final PlaylistStreamEntry playlistItem = playlistIter.next(); final int indexInHistory = Collections.binarySearch(historyStreamIds, playlistItem.getStreamId()); - - final boolean hasState = streamStatesIter.next() != null; - if (indexInHistory < 0 || hasState) { + final StreamStateEntity streamStateEntity = streamStatesIter.next(); + final long duration = playlistItem.toStreamInfoItem().getDuration(); + boolean isFinished = false; + if (streamStateEntity != null) { + isFinished = streamStateEntity.isFinished(duration); + } + final boolean isNotWatchedItem = (streamStateEntity != null + && !isFinished); + if (indexInHistory < 0) { + notWatchedItems.add(playlistItem); + } else if (isNotWatchedItem) { notWatchedItems.add(playlistItem); } else if (!thumbnailVideoRemoved && playlistManager.getPlaylistThumbnail(playlistId) From 50739277c42252eb41b406f5c6e5e45155082c15 Mon Sep 17 00:00:00 2001 From: LingYinTianMeng <95514488+LingYinTianMeng@users.noreply.github.com> Date: Tue, 3 May 2022 09:21:43 +0800 Subject: [PATCH 2/4] Update LocalPlaylistFragment.java --- .../newpipe/local/playlist/LocalPlaylistFragment.java | 10 +--------- 1 file changed, 1 insertion(+), 9 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 7cd2a3ec169..ab9d9a9b90c 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 @@ -420,15 +420,7 @@ public void removeWatchedStreams(final boolean removePartiallyWatched) { playlistItem.getStreamId()); final StreamStateEntity streamStateEntity = streamStatesIter.next(); final long duration = playlistItem.toStreamInfoItem().getDuration(); - boolean isFinished = false; - if (streamStateEntity != null) { - isFinished = streamStateEntity.isFinished(duration); - } - final boolean isNotWatchedItem = (streamStateEntity != null - && !isFinished); - if (indexInHistory < 0) { - notWatchedItems.add(playlistItem); - } else if (isNotWatchedItem) { + if (indexInHistory < 0 || (streamStateEntity != null && !streamStateEntity.isFinished(duration))) { notWatchedItems.add(playlistItem); } else if (!thumbnailVideoRemoved && playlistManager.getPlaylistThumbnail(playlistId) From c2762d3b5ec72c7188e97c9449e5d93cf68488ea Mon Sep 17 00:00:00 2001 From: LingYinTianMeng <95514488+LingYinTianMeng@users.noreply.github.com> Date: Tue, 3 May 2022 09:37:35 +0800 Subject: [PATCH 3/4] Update LocalPlaylistFragment.java --- .../schabi/newpipe/local/playlist/LocalPlaylistFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 ab9d9a9b90c..5c97d768122 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 @@ -420,7 +420,8 @@ public void removeWatchedStreams(final boolean removePartiallyWatched) { playlistItem.getStreamId()); final StreamStateEntity streamStateEntity = streamStatesIter.next(); final long duration = playlistItem.toStreamInfoItem().getDuration(); - if (indexInHistory < 0 || (streamStateEntity != null && !streamStateEntity.isFinished(duration))) { + if (indexInHistory < 0 || (streamStateEntity != null + && !streamStateEntity.isFinished(duration))) { notWatchedItems.add(playlistItem); } else if (!thumbnailVideoRemoved && playlistManager.getPlaylistThumbnail(playlistId) From 59d8c570b7412c9fac30ca02ad4d1f1049ad14df Mon Sep 17 00:00:00 2001 From: Stypox Date: Thu, 5 May 2022 18:04:33 +0200 Subject: [PATCH 4/4] Readd spaces --- .../schabi/newpipe/local/playlist/LocalPlaylistFragment.java | 2 ++ 1 file changed, 2 insertions(+) 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 5c97d768122..6023d4b10af 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 @@ -414,12 +414,14 @@ public void removeWatchedStreams(final boolean removePartiallyWatched) { } else { final Iterator streamStatesIter = recordManager .loadLocalStreamStateBatch(playlist).blockingGet().iterator(); + while (playlistIter.hasNext()) { final PlaylistStreamEntry playlistItem = playlistIter.next(); final int indexInHistory = Collections.binarySearch(historyStreamIds, playlistItem.getStreamId()); final StreamStateEntity streamStateEntity = streamStatesIter.next(); final long duration = playlistItem.toStreamInfoItem().getDuration(); + if (indexInHistory < 0 || (streamStateEntity != null && !streamStateEntity.isFinished(duration))) { notWatchedItems.add(playlistItem);