catch all exceptions when trying to focus some area

This commit is contained in:
tibbi 2017-10-21 21:46:43 +02:00
parent 406236cb2e
commit 1150eee2a6
1 changed files with 3 additions and 2 deletions

View File

@ -364,12 +364,13 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
mCallback.drawFocusRect(mLastClickX, mLastClickY)
}
mCamera!!.parameters = mParameters
try {
mCamera!!.parameters = mParameters
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))
@ -383,7 +384,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
rescheduleAutofocus()
}
}
} catch (e: RuntimeException) {
} catch (e: Exception) {
mActivity.showErrorToast(e)
}
}