Aperture: Improve CountDownView.startCountDown() API

This lets us start countdown and pass callback at the same time.

Change-Id: Icd0dccfbb00c91015abc7a33b682a676de3851ef
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index c4e1b79..e2d7649 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -1254,19 +1254,15 @@
             return
         }
 
-        countDownView.setCountDownStatusListener {
-            shutterButton.isEnabled = true
-
-            runnable()
-        }
-
         shutterButton.isEnabled = cameraMode == CameraMode.VIDEO
 
-        val rect = Rect().apply {
+        countDownView.onPreviewAreaChanged(Rect().apply {
             viewFinder.getGlobalVisibleRect(this)
+        })
+        countDownView.startCountDown(sharedPreferences.timerMode) {
+            shutterButton.isEnabled = true
+            runnable()
         }
-        countDownView.onPreviewAreaChanged(rect)
-        countDownView.startCountDown(sharedPreferences.timerMode)
     }
 
     companion object {
diff --git a/app/src/main/java/org/lineageos/aperture/ui/CountDownView.kt b/app/src/main/java/org/lineageos/aperture/ui/CountDownView.kt
index e13f162..40be1d3 100644
--- a/app/src/main/java/org/lineageos/aperture/ui/CountDownView.kt
+++ b/app/src/main/java/org/lineageos/aperture/ui/CountDownView.kt
@@ -91,22 +91,17 @@
     }
 
     /**
-     * Sets a listener that gets notified when the status of countdown has finished.
-     */
-    fun setCountDownStatusListener(listener: () -> Unit) {
-        this.listener = listener
-    }
-
-    /**
      * Starts showing countdown in the UI.
      *
      * @param sec duration of the countdown, in seconds
+     * @param listener callback for when the status of countdown has finished.
      */
-    fun startCountDown(@IntRange(from = 0) sec: Int) {
+    fun startCountDown(@IntRange(from = 0) sec: Int, listener: () -> Unit) {
         if (isCountingDown) {
             cancelCountDown()
         }
         isVisible = true
+        this.listener = listener
         remainingSecondsChanged(sec)
     }