move the autofocus cancelling code in an own function

This commit is contained in:
tibbi 2018-06-11 14:30:35 +02:00
parent 8ae53e4f2f
commit 45177dd7d9
1 changed files with 7 additions and 3 deletions

View File

@ -598,10 +598,8 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
}
mCaptureSession!!.stopRepeating()
cancelAutoFocus()
mPreviewRequestBuilder!!.apply {
set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL)
mCaptureSession!!.capture(build(), captureCallbackHandler, mBackgroundHandler)
// touch-to-focus inspired by OpenCamera
val characteristics = getCameraCharacteristics()
if (characteristics.get(CameraCharacteristics.CONTROL_MAX_REGIONS_AF) >= 1) {
@ -620,6 +618,12 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
}
}
private fun cancelAutoFocus() {
val cancelRequest = mPreviewRequestBuilder
cancelRequest!!.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_IDLE)
mCaptureSession!!.capture(cancelRequest.build(), null, mBackgroundHandler)
}
private fun convertAreaToMeteringRectangle(sensorRect: Rect, focusArea: FocusArea): MeteringRectangle {
val camera2Rect = convertRectToCamera2(sensorRect, focusArea.rect)
return MeteringRectangle(camera2Rect, focusArea.weight)