schedule autofocusing at app launch

This commit is contained in:
tibbi 2017-06-22 22:00:33 +02:00
parent 64aec3cf4f
commit 97e72417fa

View File

@ -172,6 +172,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
mSetupPreviewAfterMeasure = true mSetupPreviewAfterMeasure = true
requestLayout() requestLayout()
invalidate() invalidate()
rescheduleAutofocus()
} }
private fun getSelectedResolution(): Camera.Size { private fun getSelectedResolution(): Camera.Size {
@ -358,11 +359,8 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
if (takePictureAfter) { if (takePictureAfter) {
takePicture() takePicture()
} else if (!mIsVideoMode || !mIsRecording) { } else {
autoFocusHandler.removeCallbacksAndMessages(null) rescheduleAutofocus()
autoFocusHandler.postDelayed({
focusArea(false, false)
}, REFOCUS_PERIOD)
} }
} }
} catch (ignored: RuntimeException) { } catch (ignored: RuntimeException) {
@ -385,6 +383,15 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
return Rect(rectLeft, rectTop, rectRight, rectBottom) return Rect(rectLeft, rectTop, rectRight, rectBottom)
} }
private fun rescheduleAutofocus() {
autoFocusHandler.removeCallbacksAndMessages(null)
autoFocusHandler.postDelayed({
if (!mIsVideoMode || !mIsRecording) {
focusArea(false, false)
}
}, REFOCUS_PERIOD)
}
fun showChangeResolutionDialog() { fun showChangeResolutionDialog() {
if (mCamera != null) { if (mCamera != null) {
val oldResolution = getSelectedResolution() val oldResolution = getSelectedResolution()