Fix flashlight button state on errors
This commit is contained in:
parent
27c3aa60d0
commit
b0ea8d8ef2
|
@ -48,10 +48,10 @@ internal class CameraFlash(
|
|||
manager.setTorchMode(cameraId, enable)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
context.showErrorToast(e)
|
||||
scope.launch {
|
||||
MyCameraImpl.cameraError.emit(Unit)
|
||||
}
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -193,13 +193,14 @@ class MyCameraImpl private constructor(private val context: Context, private var
|
|||
}
|
||||
|
||||
try {
|
||||
cameraFlash.runOrToast {
|
||||
cameraFlash!!.run {
|
||||
initialize()
|
||||
toggleFlashlight(true)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
context.showErrorToast(e)
|
||||
disableFlashlight()
|
||||
return
|
||||
}
|
||||
|
||||
val mainRunnable = Runnable { stateChanged(true) }
|
||||
|
@ -212,12 +213,9 @@ class MyCameraImpl private constructor(private val context: Context, private var
|
|||
}
|
||||
|
||||
try {
|
||||
cameraFlash.runOrToast {
|
||||
toggleFlashlight(false)
|
||||
}
|
||||
cameraFlash!!.toggleFlashlight(false)
|
||||
} catch (e: Exception) {
|
||||
context.showErrorToast(e)
|
||||
disableFlashlight()
|
||||
}
|
||||
stateChanged(false)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue