fix: volume gesture tracker value does not stay within bounds (#301)

This commit is contained in:
Anil Kumar Beesetti 2023-02-23 02:39:54 +05:30 committed by GitHub
parent 01d8c11a2c
commit 56c6c72617
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -148,15 +148,14 @@ class PlayerGestureHelper(
val maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
val change = ratioChange * maxVolume
swipeGestureValueTrackerVolume += change
swipeGestureValueTrackerVolume = (swipeGestureValueTrackerVolume + change).coerceIn(0f, maxVolume.toFloat())
val toSet = swipeGestureValueTrackerVolume.toInt().coerceIn(0, maxVolume)
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, toSet, 0)
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, swipeGestureValueTrackerVolume.toInt(), 0)
activity.binding.gestureVolumeLayout.visibility = View.VISIBLE
activity.binding.gestureVolumeProgressBar.max = maxVolume
activity.binding.gestureVolumeProgressBar.progress = toSet
activity.binding.gestureVolumeText.text = "${(toSet.toFloat() / maxVolume.toFloat()).times(100).toInt()}%"
activity.binding.gestureVolumeProgressBar.progress = swipeGestureValueTrackerVolume.toInt()
activity.binding.gestureVolumeText.text = "${(swipeGestureValueTrackerVolume / maxVolume.toFloat()).times(100).toInt()}%"
swipeGestureVolumeOpen = true
} else {