From cd9ff1a48fc2b8debd97a115b7e066e234945578 Mon Sep 17 00:00:00 2001 From: polymorphicshade Date: Tue, 15 Dec 2020 00:24:10 -0700 Subject: [PATCH] SponsorBlock: Fixed an issue where marked segments would persist on videos with no segments The MarkableSeekBar now has a way to clear the marked segments. --- .../org/schabi/newpipe/player/VideoPlayer.java | 14 +++++++------- .../org/schabi/newpipe/views/MarkableSeekBar.java | 5 +++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java index 6781502ea..e419dd672 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java @@ -623,18 +623,18 @@ public abstract class VideoPlayer extends BasePlayer } private void markSegments() { - final VideoSegment[] segments = getVideoSegments(); - - if (segments == null || segments.length == 0) { - return; - } - if (!(playbackSeekBar instanceof MarkableSeekBar)) { return; } final MarkableSeekBar markableSeekBar = (MarkableSeekBar) playbackSeekBar; - markableSeekBar.seekBarMarkers.clear(); + markableSeekBar.clearMarkers(); + + final VideoSegment[] segments = getVideoSegments(); + + if (segments == null || segments.length == 0) { + return; + } for (final VideoSegment segment : segments) { final Integer color = parseSegmentCategory(segment.category); diff --git a/app/src/main/java/org/schabi/newpipe/views/MarkableSeekBar.java b/app/src/main/java/org/schabi/newpipe/views/MarkableSeekBar.java index d37c5c58b..82dcda0c6 100644 --- a/app/src/main/java/org/schabi/newpipe/views/MarkableSeekBar.java +++ b/app/src/main/java/org/schabi/newpipe/views/MarkableSeekBar.java @@ -101,4 +101,9 @@ public class MarkableSeekBar extends AppCompatSeekBar { super.setProgressDrawable(layerDrawable); } + + public void clearMarkers() { + seekBarMarkers.clear(); + super.setProgressDrawable(originalProgressDrawable); + } }