From 93c4cd72268d16aa7eb25218a55ab721ae3cfcb3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 6 Nov 2017 12:26:18 +0100 Subject: [PATCH] fix #19, release camera on flashlight stoping --- .../com/simplemobiletools/flashlight/helpers/MyCameraImpl.kt | 5 +++++ 1 file changed, 5 insertions(+) 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 c896dd1..a0ed669 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyCameraImpl.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyCameraImpl.kt @@ -112,6 +112,10 @@ class MyCameraImpl(val context: Context) { } private fun checkFlashlight() { + if (camera == null) { + handleCameraSetup() + } + if (isFlashlightOn) { enableFlashlight() } else { @@ -158,6 +162,7 @@ class MyCameraImpl(val context: Context) { camera!!.parameters = params } stateChanged(false) + releaseCamera() } private fun stateChanged(isEnabled: Boolean) {