mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-06-27 09:02:59 +02:00
properly handle the case when surface is prepared earlier than the camera
This commit is contained in:
@ -50,6 +50,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
||||
private var mIsSixteenToNine = false
|
||||
private var mWasZooming = false
|
||||
private var mIsPreviewShown = false
|
||||
private var mWasCameraPreviewSet = false
|
||||
private var mLastClickX = 0
|
||||
private var mLastClickY = 0
|
||||
private var mCurrCameraId = 0
|
||||
@ -132,6 +133,10 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
||||
initRecorder()
|
||||
}
|
||||
|
||||
if (!mWasCameraPreviewSet && mIsSurfaceCreated) {
|
||||
mCamera!!.setPreviewDisplay(mSurfaceHolder)
|
||||
mWasCameraPreviewSet = true
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@ -448,6 +453,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
||||
override fun surfaceCreated(holder: SurfaceHolder) {
|
||||
mIsSurfaceCreated = true
|
||||
try {
|
||||
mWasCameraPreviewSet = mCamera != null
|
||||
mCamera?.setPreviewDisplay(mSurfaceHolder)
|
||||
|
||||
if (mSwitchToVideoAsap)
|
||||
|
Reference in New Issue
Block a user