From 091847b1311e358a134c55ca7c012475d48860c5 Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Tue, 13 Oct 2020 20:09:24 +1100 Subject: [PATCH] Restrict the waveform seek bar progress value to a 0..1 range. --- src/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt b/src/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt index dc7c83eb46..95ed82f215 100644 --- a/src/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt +++ b/src/org/thoughtcrime/securesms/loki/views/WaveformSeekBar.kt @@ -13,6 +13,7 @@ import android.view.MotionEvent import android.view.View import android.view.ViewConfiguration import android.view.animation.DecelerateInterpolator +import androidx.core.math.MathUtils import network.loki.messenger.R import java.lang.Math.abs import kotlin.math.max @@ -227,11 +228,11 @@ class WaveformSeekBar : View { } private fun updateProgress(progress: Float, notify: Boolean) { - _progress = progress + _progress = MathUtils.clamp(progress, 0f, 1f) invalidate() if (notify) { - progressChangeListener?.onProgressChanged(this, progress, true) + progressChangeListener?.onProgressChanged(this, _progress, true) } }