Aperture: Use when() for startRecording event handling
Change-Id: I6acba17155bc7872efd21eb37e40593eab6ecfe8
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index 60aae30..67d3ad4 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -561,24 +561,25 @@
audioConfig,
cameraExecutor
) {
- if (it is VideoRecordEvent.Status) {
- runOnUiThread {
+ when (it) {
+ is VideoRecordEvent.Status -> runOnUiThread {
recordingTime = it.recordingStats.recordedDurationNanos
recordChip.isVisible = true
}
- } else if (it is VideoRecordEvent.Finalize) {
- runOnUiThread {
- startShutterAnimation(ShutterAnimation.VideoEnd)
- recordChip.isVisible = false
+ is VideoRecordEvent.Finalize -> {
+ runOnUiThread {
+ startShutterAnimation(ShutterAnimation.VideoEnd)
+ recordChip.isVisible = false
+ }
+ cameraSoundsUtils.playStopVideoRecording()
+ if (it.error != VideoRecordEvent.Finalize.ERROR_NO_VALID_DATA) {
+ sharedPreferences.lastSavedUri = it.outputResults.outputUri
+ updateGalleryButton(it.outputResults.outputUri)
+ Log.d(LOG_TAG, "Video capture succeeded: ${it.outputResults.outputUri}")
+ tookSomething = true
+ }
+ recording = null
}
- cameraSoundsUtils.playStopVideoRecording()
- if (it.error != VideoRecordEvent.Finalize.ERROR_NO_VALID_DATA) {
- sharedPreferences.lastSavedUri = it.outputResults.outputUri
- updateGalleryButton(it.outputResults.outputUri)
- Log.d(LOG_TAG, "Video capture succeeded: ${it.outputResults.outputUri}")
- tookSomething = true
- }
- recording = null
}
}
}