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)
|
manager.setTorchMode(cameraId, enable)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
context.showErrorToast(e)
|
|
||||||
scope.launch {
|
scope.launch {
|
||||||
MyCameraImpl.cameraError.emit(Unit)
|
MyCameraImpl.cameraError.emit(Unit)
|
||||||
}
|
}
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,13 +193,14 @@ class MyCameraImpl private constructor(private val context: Context, private var
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cameraFlash.runOrToast {
|
cameraFlash!!.run {
|
||||||
initialize()
|
initialize()
|
||||||
toggleFlashlight(true)
|
toggleFlashlight(true)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
context.showErrorToast(e)
|
context.showErrorToast(e)
|
||||||
disableFlashlight()
|
disableFlashlight()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val mainRunnable = Runnable { stateChanged(true) }
|
val mainRunnable = Runnable { stateChanged(true) }
|
||||||
|
@ -212,12 +213,9 @@ class MyCameraImpl private constructor(private val context: Context, private var
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cameraFlash.runOrToast {
|
cameraFlash!!.toggleFlashlight(false)
|
||||||
toggleFlashlight(false)
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
context.showErrorToast(e)
|
context.showErrorToast(e)
|
||||||
disableFlashlight()
|
|
||||||
}
|
}
|
||||||
stateChanged(false)
|
stateChanged(false)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue