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