fix focusing on some devices
This commit is contained in:
parent
7103b447bc
commit
4bd40976f8
|
@ -361,6 +361,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
||||||
mLastClickX = width / 2
|
mLastClickX = width / 2
|
||||||
mLastClickY = height / 2
|
mLastClickY = height / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
val focusRect = calculateFocusArea(mLastClickX.toFloat(), mLastClickY.toFloat())
|
val focusRect = calculateFocusArea(mLastClickX.toFloat(), mLastClickY.toFloat())
|
||||||
val focusAreas = ArrayList<Camera.Area>(1)
|
val focusAreas = ArrayList<Camera.Area>(1)
|
||||||
focusAreas.add(Camera.Area(focusRect, 1000))
|
focusAreas.add(Camera.Area(focusRect, 1000))
|
||||||
|
@ -371,6 +372,11 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
val focusModes = mParameters!!.supportedFocusModes
|
||||||
|
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
|
||||||
|
mParameters!!.focusMode = Camera.Parameters.FOCUS_MODE_AUTO
|
||||||
|
}
|
||||||
|
|
||||||
mCamera!!.parameters = mParameters
|
mCamera!!.parameters = mParameters
|
||||||
mCamera!!.autoFocus { success, camera ->
|
mCamera!!.autoFocus { success, camera ->
|
||||||
if (camera == null || mCamera == null) {
|
if (camera == null || mCamera == null) {
|
||||||
|
@ -378,7 +384,6 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
||||||
}
|
}
|
||||||
|
|
||||||
camera.cancelAutoFocus()
|
camera.cancelAutoFocus()
|
||||||
val focusModes = mParameters!!.supportedFocusModes
|
|
||||||
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE))
|
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE))
|
||||||
mParameters!!.focusMode = Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE
|
mParameters!!.focusMode = Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue