adding a crashfix with zero division

This commit is contained in:
tibbi 2021-02-18 18:16:12 +01:00
parent 87627aef41
commit cf3e27a25d

View file

@ -156,6 +156,10 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
val stream = AudioManager.STREAM_MUSIC
val maxVolume = activity!!.audioManager.getStreamMaxVolume(stream)
val percentPerPoint = 100 / maxVolume
if (percentPerPoint == 0) {
return
}
val addPoints = percent / percentPerPoint
val newVolume = Math.min(maxVolume, Math.max(0, mTouchDownValue + addPoints))
activity!!.audioManager.setStreamVolume(stream, newVolume, 0)