-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix removing only fully watched videos from playlist #8259
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I forgot about this when I improved how stream states are saved
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic was difficult to understand, this is clearer in my opinion (also keep the newline)
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); | |
final StreamStateEntity streamStateEntity = streamStatesIter.next(); | |
final long duration = playlistItem.toStreamInfoItem().getDuration(); | |
if (indexInHistory < 0 || (streamStateEntity != null && streamStateEntity.isFinished(duration))) { | |
notWatchedItems.add(playlistItem); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is indexInHistory < 0 || (streamStateEntity != null && !streamStateEntity.isFinished(duration)), there should be
a "!" before streamStateEntity.isFinished(duration)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops, yes, you are right
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have modified it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces should be kept. Other than that, thanks :-)
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Outdated
Show resolved
Hide resolved
app/src/main/java/org/schabi/newpipe/local/playlist/LocalPlaylistFragment.java
Show resolved
Hide resolved
Kudos, SonarCloud Quality Gate passed! |
What is it?
Description of the changes in your PR
Before fixing, in the playlist view press "Remove watched', then press "OK", no videos are removed. After fixing, all completely watched videos can be removed.
Before/After Screenshots/Screen Record
before.mp4
After.mp4
Fixes the following issue(s)
APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.
Due diligence