schedule autofocusing at app launch

This commit is contained in:
tibbi 2017-06-22 22:00:33 +02:00
parent 64aec3cf4f
commit 97e72417fa
1 changed files with 12 additions and 5 deletions

View File

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