adding some crashfixes

This commit is contained in:
tibbi 2022-11-17 23:32:48 +01:00
parent 128f01c751
commit e28525f23c
2 changed files with 8 additions and 3 deletions

View File

@ -62,7 +62,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:af11ea2e30' implementation 'com.github.SimpleMobileTools:Simple-Commons:f538687d6e'
implementation 'org.greenrobot:eventbus:3.3.1' implementation 'org.greenrobot:eventbus:3.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
} }

View File

@ -10,9 +10,14 @@ class LollipopCameraFlash : CameraFlash {
private var params: Camera.Parameters? = null private var params: Camera.Parameters? = null
override fun toggleFlashlight(enable: Boolean) { override fun toggleFlashlight(enable: Boolean) {
if (camera == null || params == null || camera!!.parameters == null) { try {
if (camera == null || params == null || camera!!.parameters == null) {
return
}
} catch (e: Exception) {
return return
} }
val flashMode = if (enable) Camera.Parameters.FLASH_MODE_ON else Camera.Parameters.FLASH_MODE_OFF val flashMode = if (enable) Camera.Parameters.FLASH_MODE_ON else Camera.Parameters.FLASH_MODE_OFF
params!!.flashMode = flashMode params!!.flashMode = flashMode
camera!!.parameters = params camera!!.parameters = params
@ -31,7 +36,7 @@ class LollipopCameraFlash : CameraFlash {
} }
override fun release() { override fun release() {
camera!!.release() camera?.release()
camera = null camera = null
} }
} }