toggle Camera availability when appropriate
This commit is contained in:
parent
c521b33ed9
commit
209700dc72
|
@ -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) {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue