try refocusing the selected area every 3 secs

This commit is contained in:
tibbi 2017-05-07 12:09:26 +02:00
parent ca1cb05b93
commit d59577512f
1 changed files with 8 additions and 2 deletions

View File

@ -306,7 +306,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
mCanTakePicture = true mCanTakePicture = true
} }
private fun focusArea(takePictureAfter: Boolean) { private fun focusArea(takePictureAfter: Boolean, showFocusRect: Boolean = true) {
if (mCamera == null) if (mCamera == null)
return return
@ -316,7 +316,9 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
val focusAreas = ArrayList<Camera.Area>(1) val focusAreas = ArrayList<Camera.Area>(1)
focusAreas.add(Camera.Area(focusRect, 1000)) focusAreas.add(Camera.Area(focusRect, 1000))
mParameters!!.focusAreas = focusAreas mParameters!!.focusAreas = focusAreas
mCallback.drawFocusRect(mLastClickX, mLastClickY)
if (showFocusRect)
mCallback.drawFocusRect(mLastClickX, mLastClickY)
} }
mCamera!!.parameters = mParameters mCamera!!.parameters = mParameters
@ -329,6 +331,10 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
camera.parameters = mParameters camera.parameters = mParameters
if (takePictureAfter) { if (takePictureAfter) {
takePicture() takePicture()
} else {
Handler().postDelayed({
focusArea(false, false)
}, 3000)
} }
} }
} }