catch exceptions thrown at getting device brightness
This commit is contained in:
parent
4809f54bae
commit
711c714686
1 changed files with 9 additions and 2 deletions
|
@ -69,8 +69,9 @@ class MediaSideScroll(val activity: Activity, val slideInfoView: TextView, val c
|
||||||
mLastTouchY = event.y
|
mLastTouchY = event.y
|
||||||
mTouchDownTime = System.currentTimeMillis()
|
mTouchDownTime = System.currentTimeMillis()
|
||||||
mSlideInfoText = "${activity.getString(R.string.brightness)}:\n"
|
mSlideInfoText = "${activity.getString(R.string.brightness)}:\n"
|
||||||
if (mTouchDownBrightness == -1)
|
if (mTouchDownBrightness == -1) {
|
||||||
mTouchDownBrightness = getCurrentBrightness()
|
mTouchDownBrightness = getCurrentBrightness()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
val diffX = mTouchDownX - event.x
|
val diffX = mTouchDownX - event.x
|
||||||
|
@ -102,7 +103,13 @@ class MediaSideScroll(val activity: Activity, val slideInfoView: TextView, val c
|
||||||
|
|
||||||
private fun getCurrentVolume() = activity.audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
private fun getCurrentVolume() = activity.audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||||
|
|
||||||
private fun getCurrentBrightness() = Settings.System.getInt(activity.contentResolver, Settings.System.SCREEN_BRIGHTNESS)
|
private fun getCurrentBrightness(): Int {
|
||||||
|
return try {
|
||||||
|
Settings.System.getInt(activity.contentResolver, Settings.System.SCREEN_BRIGHTNESS)
|
||||||
|
} catch (e: Settings.SettingNotFoundException) {
|
||||||
|
70
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun volumePercentChanged(percent: Int) {
|
private fun volumePercentChanged(percent: Int) {
|
||||||
val stream = AudioManager.STREAM_MUSIC
|
val stream = AudioManager.STREAM_MUSIC
|
||||||
|
|
Loading…
Reference in a new issue