adding some crashfixes

This commit is contained in:
tibbi 2023-07-26 22:49:30 +02:00
parent 7ac1c08075
commit c2e11365d5
3 changed files with 10 additions and 6 deletions

View File

@ -63,7 +63,7 @@ android {
}
dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:e7d5ba6864'
implementation 'com.github.SimpleMobileTools:Simple-Commons:fad9b2cdb0'
implementation 'androidx.documentfile:documentfile:1.0.1'
implementation "androidx.exifinterface:exifinterface:1.3.5"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"

View File

@ -82,6 +82,7 @@ class MediaActionSound(private val context: Context) {
soundToBePlayed = sound
sound.state = STATE_LOADED
}
else -> Log.e(TAG, "OnLoadCompleteListener() called in wrong state: ${sound.state} for sound: ${sound.mediaSound}")
}
}
@ -112,6 +113,7 @@ class MediaActionSound(private val context: Context) {
break
}
}
is MediaSound.RawResSound -> {
id = soundPool!!.load(context, sound.mediaSound.resId, 1)
}
@ -127,7 +129,7 @@ class MediaActionSound(private val context: Context) {
}
fun load(mediaSound: MediaSound) {
val sound = sounds.first { it.mediaSound == mediaSound }
val sound = sounds.firstOrNull() { it.mediaSound == mediaSound } ?: return
synchronized(sound) {
when (sound.state) {
STATE_NOT_LOADED -> {
@ -137,6 +139,7 @@ class MediaActionSound(private val context: Context) {
}
}
}
else -> Log.e(TAG, "load() called in wrong state: $sound for sound: $mediaSound")
}
}
@ -161,10 +164,12 @@ class MediaActionSound(private val context: Context) {
sound.state = STATE_LOADING_PLAY_REQUESTED
}
}
STATE_LOADING -> sound.state = STATE_LOADING_PLAY_REQUESTED
STATE_LOADED -> {
playWithSoundPool(sound)
}
else -> Log.e(TAG, "play() called in wrong state: ${sound.state} for sound: $mediaSound")
}
}
@ -195,6 +200,7 @@ class MediaActionSound(private val context: Context) {
STATE_LOADED -> {
soundPool!!.stop(sound.streamId)
}
else -> Log.w(TAG, "stop() should be called after sound is loaded for sound: $mediaSound")
}
}

View File

@ -463,14 +463,12 @@ class CameraXPreview(
when (flashMode) {
FLASH_MODE_OFF -> FLASH_MODE_ON
FLASH_MODE_ON -> FLASH_MODE_AUTO
FLASH_MODE_AUTO -> FLASH_MODE_OFF
else -> throw IllegalArgumentException("Unknown mode: $flashMode")
else -> FLASH_MODE_OFF
}
} else {
when (flashMode) {
FLASH_MODE_OFF -> FLASH_MODE_ON
FLASH_MODE_ON -> FLASH_MODE_OFF
else -> throw IllegalArgumentException("Unknown mode: $flashMode")
else -> FLASH_MODE_OFF
}
}
setFlashlightState(newFlashMode.toAppFlashMode())