Properly reflect flash state in main screen icons

This commit is contained in:
Ensar Sarajčić
2023-10-02 12:59:57 +02:00
parent 3414295887
commit 81096e35a6
2 changed files with 4 additions and 15 deletions

View File

@ -394,20 +394,7 @@ class MainActivity : SimpleActivity() {
} }
private fun checkState(isEnabled: Boolean) { private fun checkState(isEnabled: Boolean) {
if (isEnabled) { _flashlightOn.value = isEnabled
enableFlashlight()
} else {
disableFlashlight()
}
}
fun enableFlashlight() {
_flashlightOn.value = true
}
private fun disableFlashlight() {
_flashlightOn.value = false
} }
@Subscribe @Subscribe
@ -428,7 +415,7 @@ class MainActivity : SimpleActivity() {
@Subscribe @Subscribe
fun cameraUnavailable(event: Events.CameraUnavailable) { fun cameraUnavailable(event: Events.CameraUnavailable) {
getApplication<Application>().toast(R.string.camera_error) getApplication<Application>().toast(R.string.camera_error)
disableFlashlight() _flashlightOn.value = false
} }
override fun onCleared() { override fun onCleared() {

View File

@ -276,8 +276,10 @@ class MyCameraImpl private constructor(val context: Context, private var cameraT
shouldStroboscopeStop = false shouldStroboscopeStop = false
if (isStroboSOS) { if (isStroboSOS) {
isSOSRunning = false isSOSRunning = false
EventBus.getDefault().post(Events.StopSOS())
} else { } else {
isStroboscopeRunning = false isStroboscopeRunning = false
EventBus.getDefault().post(Events.StopStroboscope())
} }
when { when {