Restrict the waveform seek bar progress value to a 0..1 range.

This commit is contained in:
Anton Chekulaev 2020-10-13 20:09:24 +11:00
parent 793e6bf10f
commit 091847b131

View File

@ -13,6 +13,7 @@ import android.view.MotionEvent
import android.view.View import android.view.View
import android.view.ViewConfiguration import android.view.ViewConfiguration
import android.view.animation.DecelerateInterpolator import android.view.animation.DecelerateInterpolator
import androidx.core.math.MathUtils
import network.loki.messenger.R import network.loki.messenger.R
import java.lang.Math.abs import java.lang.Math.abs
import kotlin.math.max import kotlin.math.max
@ -227,11 +228,11 @@ class WaveformSeekBar : View {
} }
private fun updateProgress(progress: Float, notify: Boolean) { private fun updateProgress(progress: Float, notify: Boolean) {
_progress = progress _progress = MathUtils.clamp(progress, 0f, 1f)
invalidate() invalidate()
if (notify) { if (notify) {
progressChangeListener?.onProgressChanged(this, progress, true) progressChangeListener?.onProgressChanged(this, _progress, true)
} }
} }