mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
adding a crashfix with zero division
This commit is contained in:
parent
87627aef41
commit
cf3e27a25d
1 changed files with 4 additions and 0 deletions
|
@ -156,6 +156,10 @@ class MediaSideScroll(context: Context, attrs: AttributeSet) : RelativeLayout(co
|
||||||
val stream = AudioManager.STREAM_MUSIC
|
val stream = AudioManager.STREAM_MUSIC
|
||||||
val maxVolume = activity!!.audioManager.getStreamMaxVolume(stream)
|
val maxVolume = activity!!.audioManager.getStreamMaxVolume(stream)
|
||||||
val percentPerPoint = 100 / maxVolume
|
val percentPerPoint = 100 / maxVolume
|
||||||
|
if (percentPerPoint == 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val addPoints = percent / percentPerPoint
|
val addPoints = percent / percentPerPoint
|
||||||
val newVolume = Math.min(maxVolume, Math.max(0, mTouchDownValue + addPoints))
|
val newVolume = Math.min(maxVolume, Math.max(0, mTouchDownValue + addPoints))
|
||||||
activity!!.audioManager.setStreamVolume(stream, newVolume, 0)
|
activity!!.audioManager.setStreamVolume(stream, newVolume, 0)
|
||||||
|
|
Loading…
Reference in a new issue