toggle Camera availability when appropriate

This commit is contained in:
tibbi 2018-05-28 22:43:38 +02:00
parent c521b33ed9
commit 209700dc72
1 changed files with 4 additions and 3 deletions

View File

@ -239,18 +239,21 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
mCameraOpenCloseLock.release()
mCameraDevice = cameraDevice
createCameraPreviewSession()
mActivity.setIsCameraAvailable(true)
}
override fun onDisconnected(cameraDevice: CameraDevice) {
mCameraOpenCloseLock.release()
cameraDevice.close()
mCameraDevice = null
mActivity.setIsCameraAvailable(false)
}
override fun onError(cameraDevice: CameraDevice, error: Int) {
mCameraOpenCloseLock.release()
cameraDevice.close()
mCameraDevice = null
mActivity.setIsCameraAvailable(false)
}
}
@ -456,9 +459,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
override fun deviceOrientationChanged() {
}
override fun resumeCamera(): Boolean {
return false
}
override fun resumeCamera() = true
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {}
}