Skip to content

Instantly share code, notes, and snippets.

@husaynhakeem
Last active December 4, 2020 17:50
Show Gist options
  • Save husaynhakeem/34e73067fa6c4c5c5318e6811b3c166d to your computer and use it in GitHub Desktop.
Save husaynhakeem/34e73067fa6c4c5c5318e6811b3c166d to your computer and use it in GitHub Desktop.
fun toggleCamera() {
if (cameraController.cameraSelector == CameraSelector.DEFAULT_BACK_CAMERA
&& cameraController.hasCamera(CameraSelector.DEFAULT_FRONT_CAMERA) {
cameraController.cameraSelector = CameraSelector.DEFAULT_FRONT_CAMERA
} else if (cameraController.cameraSelector == CameraSelector.DEFAULT_FRONT_CAMERA
&& cameraController.hasCamera(CameraSelector.DEFAULT_BACK_CAMERA) {
cameraController.cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment