From 622ebde68ff87e320378b0cae956a4d15e3e6668 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 6 Aug 2017 19:39:11 +0200 Subject: [PATCH] tweak the volume setter a bit --- .../com/simplemobiletools/gallery/fragments/VideoFragment.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt index a816ee4bb..ac79cdec9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -138,7 +138,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee val diffY = mTouchDownY - event.y if (Math.abs(diffY) > Math.abs(diffX)) { - var percent = ((diffY / ViewPagerActivity.screenHeight) * 100).toInt() * 2 + var percent = ((diffY / ViewPagerActivity.screenHeight) * 100).toInt() * 3 percent = Math.min(100, Math.max(-100, percent)) volumePercentChanged(percent) } @@ -156,7 +156,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee private fun volumePercentChanged(percent: Int) { val stream = AudioManager.STREAM_MUSIC val maxVolume = context.audioManager.getStreamMaxVolume(stream) - val percentPerPoint = Math.ceil(100 / maxVolume.toDouble()).toInt() + val percentPerPoint = 100 / maxVolume val addPoints = percent / percentPerPoint val newVolume = Math.min(maxVolume, Math.max(0, mTouchDownVolume + addPoints)) context.audioManager.setStreamVolume(stream, newVolume, 0)