diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/CameraFlash.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/CameraFlash.kt index 186b5d7..997f70b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/CameraFlash.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/CameraFlash.kt @@ -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 } } diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyCameraImpl.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyCameraImpl.kt index 9210b7d..0fb1b0c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyCameraImpl.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyCameraImpl.kt @@ -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) }