Revert "Aperture: Only bind CameraController to lifecycle once"

* We need it to trigger STREAMING event

This reverts commit 09240cc91bfc457f8ebdb14c5c393076d0549423.

Change-Id: I6a1f30ec459b6962f2aabf30a6d0b71a84bdd4c9
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index 60727fd..e9cabc1 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -174,9 +174,6 @@
         // Initialize sounds utils
         cameraSoundsUtils = CameraSoundsUtils(sharedPreferences)
 
-        // Bind camera controller to lifecycle
-        cameraController.bindToLifecycle(this)
-
         // Set top bar button callbacks
         aspectRatioButton.setOnClickListener { cycleAspectRatio() }
         effectButton.setOnClickListener { cyclePhotoEffects() }
@@ -437,6 +434,9 @@
     @androidx.camera.core.ExperimentalZeroShutterLag
     @androidx.camera.view.video.ExperimentalVideo
     private fun bindCameraUseCases() {
+        // Unbind previous use cases
+        cameraController.unbind()
+
         isTakingPhoto = false
 
         // Hide grid until preview is ready
@@ -503,6 +503,9 @@
         // Restore settings that needs a rebind
         cameraController.imageCaptureMode = sharedPreferences.photoCaptureMode
 
+        // Bind camera controller to lifecycle
+        cameraController.bindToLifecycle(this)
+
         // Get a stable reference to CameraInfo
         // We can hardcode the first one in the filter as long as we use DEFAULT_*_CAMERA
         camera = PhysicalCamera(cameraSelector.filter(cameraProvider.availableCameraInfos)[0])