move the autofocus cancelling code in an own function
This commit is contained in:
parent
8ae53e4f2f
commit
45177dd7d9
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue