diff options
author | Jonas Burian <jonas.burian@protonmail.com> | 2021-05-09 11:04:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-09 11:04:31 +0200 |
commit | 508cea67d1d5a0fd051a1636e402f31f1c7fc39a (patch) | |
tree | 05b1f8db66c8a3afb092158a9ac8bab3e8121122 /app/src | |
parent | 3c808c13930cade8079ef3aa1c83d8321035bfd2 (diff) | |
download | AntennaPod-508cea67d1d5a0fd051a1636e402f31f1c7fc39a.zip |
Fix chapter seekbar issues (#5142)
Buffering indicator drawn incorrectly
Not refreshing divider positions with duration change
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java | 11 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java | 11 |
2 files changed, 16 insertions, 6 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java index 7c821ba23..d5807cd90 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java @@ -98,6 +98,7 @@ public class AudioPlayerFragment extends Fragment implements private boolean hasChapters = false; private boolean seekedToChapterStart = false; private int currentChapterIndex = -1; + private int duration; private TabLayoutMediator tabLayoutMediator; @Override @@ -195,10 +196,9 @@ public class AudioPlayerFragment extends Fragment implements if (hasChapters) { List<Chapter> chapters = media.getChapters(); dividerPos = new float[chapters.size()]; - float duration = media.getDuration(); for (int i = 0; i < chapters.size(); i++) { - dividerPos[i] = chapters.get(i).getStart() / duration; + dividerPos[i] = chapters.get(i).getStart() / (float) duration; } } @@ -418,6 +418,8 @@ public class AudioPlayerFragment extends Fragment implements return; } + duration = controller.getDuration(); + if (media != null && media.getChapters() != null) { setHasChapters(media.getChapters().size() > 0); currentChapterIndex = ChapterUtils.getCurrentChapterIndex(media, controller.getPosition()); @@ -425,7 +427,7 @@ public class AudioPlayerFragment extends Fragment implements setHasChapters(false); currentChapterIndex = -1; } - updatePosition(new PlaybackPositionEvent(controller.getPosition(), controller.getDuration())); + updatePosition(new PlaybackPositionEvent(controller.getPosition(), duration)); updatePlaybackSpeedButton(media); setChapterDividers(media); setupOptionsMenu(media); @@ -499,6 +501,7 @@ public class AudioPlayerFragment extends Fragment implements if (controller == null || txtvLength == null) { return; } + if (fromUser) { float prog = progress / ((float) seekBar.getMax()); TimeSpeedConverter converter = new TimeSpeedConverter(controller.getCurrentPlaybackSpeedMultiplier()); @@ -518,6 +521,8 @@ public class AudioPlayerFragment extends Fragment implements } else { txtvSeek.setText(Converter.getDurationStringLong(position)); } + } else if (duration != controller.getDuration()) { + updateUi(controller.getMedia()); } } diff --git a/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java b/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java index e14b000a7..ba7acb847 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java +++ b/app/src/main/java/de/danoeh/antennapod/view/ChapterSeekBar.java @@ -118,6 +118,14 @@ public class ChapterSeekBar extends androidx.appcompat.widget.AppCompatSeekBar { canvas.drawRect(left, top, right, bottom, paintBackground); + if (progressSecondary > 0 && progressSecondary < width) { + if (right < progressSecondary) { + canvas.drawRect(left, top, right, bottom, paintBackground); + } else if (progressSecondary > left) { + canvas.drawRect(left, top, progressSecondary, bottom, paintBackground); + } + } + if (right < progressPrimary) { currChapter = i + 1; canvas.drawRect(left, top, right, bottom, paintProgressPrimary); @@ -125,9 +133,6 @@ public class ChapterSeekBar extends androidx.appcompat.widget.AppCompatSeekBar { canvas.drawRect(leftCurr, topExpanded, rightCurr, bottomExpanded, paintBackground); canvas.drawRect(leftCurr, topExpanded, progressPrimary, bottomExpanded, paintProgressPrimary); } else { - if (progressSecondary > leftCurr) { - canvas.drawRect(leftCurr, top, progressSecondary, bottom, paintBackground); - } canvas.drawRect(leftCurr, top, progressPrimary, bottom, paintProgressPrimary); } } |