adding an extra check to avoid some rounding or overflowing issues

This commit is contained in:
tibbi 2021-03-06 21:35:51 +01:00
parent e0fd08ff1e
commit 95b6943603

View file

@ -46,7 +46,7 @@ class PlaybackSpeedFragment : BottomSheetDialogFragment() {
playback_speed_seekbar.progress = config.playbackSpeedProgress
playback_speed_seekbar.onSeekBarChangeListener { progress ->
val playbackSpeed = when {
var playbackSpeed = when {
progress < halfProgress -> {
val lowerProgressPercent = progress / halfProgress.toFloat()
val lowerProgress = (1 - MIN_PLAYBACK_SPEED) * lowerProgressPercent + MIN_PLAYBACK_SPEED
@ -61,6 +61,7 @@ class PlaybackSpeedFragment : BottomSheetDialogFragment() {
}
val stepMultiplier = 1 / STEP
playbackSpeed = Math.min(Math.max(playbackSpeed, MIN_PLAYBACK_SPEED), MAX_PLAYBACK_SPEED)
val rounded = Math.round(playbackSpeed * stepMultiplier) / stepMultiplier
config.playbackSpeed = rounded
config.playbackSpeedProgress = progress