From eb6b5c143dcc5948110496a806801fcae4fabc97 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 20 Sep 2017 23:22:22 +0200 Subject: [PATCH] add some camera null checks at autofocusing --- app/src/main/kotlin/com/simplemobiletools/camera/Preview.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/Preview.kt b/app/src/main/kotlin/com/simplemobiletools/camera/Preview.kt index 9cf85ee0..a7aa7a2f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/Preview.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/Preview.kt @@ -350,6 +350,9 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan mCamera!!.parameters = mParameters try { mCamera!!.autoFocus { success, camera -> + if (camera == null || mCamera == null) { + return@autoFocus + } camera.cancelAutoFocus() val focusModes = mParameters!!.supportedFocusModes if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE))