add some camera null checks at autofocusing

This commit is contained in:
tibbi 2017-09-20 23:22:22 +02:00
parent 95c763cd62
commit eb6b5c143d
1 changed files with 3 additions and 0 deletions

View File

@ -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))