From 7a9e73fb131b67d9689437568ccb9c2e1dde947b Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Thu, 8 Oct 2020 15:42:32 +1100 Subject: [PATCH] Properly handle seek bar input events. --- .../thoughtcrime/securesms/audio/AudioSlidePlayer.java | 8 +++----- .../thoughtcrime/securesms/loki/views/WaveformSeekBar.kt | 4 +++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/org/thoughtcrime/securesms/audio/AudioSlidePlayer.java b/src/org/thoughtcrime/securesms/audio/AudioSlidePlayer.java index 4c7878e543..a737e3c264 100644 --- a/src/org/thoughtcrime/securesms/audio/AudioSlidePlayer.java +++ b/src/org/thoughtcrime/securesms/audio/AudioSlidePlayer.java @@ -246,12 +246,10 @@ public class AudioSlidePlayer implements SensorEventListener { } public synchronized void seekTo(double progress) throws IOException { - if (mediaPlayer == null) return; - - if (isReady()) { - mediaPlayer.seekTo((long) (mediaPlayer.getDuration() * progress)); - } else { + if (mediaPlayer == null || !isReady()) { play(progress); + } else { + mediaPlayer.seekTo((long) (mediaPlayer.getDuration() * progress)); } } diff --git a/src/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt b/src/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt index 6eabd872fb..8434186c2d 100644 --- a/src/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt +++ b/src/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt @@ -249,9 +249,11 @@ class WaveformSeekBar : View { if (abs(event.x - touchDownX) > scaledTouchSlop) { updateProgress(event, false) } - performClick() } + MotionEvent.ACTION_CANCEL -> { + userSeeking = false + } } return true }