Aperture: Inline handler inside CountDownView
Change-Id: I269e455a8f9efb1455166c3cca71b90e140146f1
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 3bf3e53..2a4b6c5 100644
--- a/app/src/main/java/org/lineageos/aperture/ui/CountDownView.kt
+++ b/app/src/main/java/org/lineageos/aperture/ui/CountDownView.kt
@@ -31,9 +31,17 @@
}
private var remainingSeconds = 0
private lateinit var listener: () -> Unit
- private val handler = MainHandler(Looper.getMainLooper())
private val previewArea = Rect()
+ private val handler = object : Handler(Looper.getMainLooper()) {
+ override fun handleMessage(msg: Message) {
+ super.handleMessage(msg)
+ when (msg.what) {
+ SET_TIMER_TEXT -> remainingSecondsChanged(remainingSeconds - 1)
+ }
+ }
+ }
+
/**
* Returns whether countdown is on-going.
*/
@@ -113,15 +121,6 @@
}
}
- private inner class MainHandler(looper: Looper) : Handler(looper) {
- override fun handleMessage(message: Message) {
- when (message.what) {
- SET_TIMER_TEXT -> remainingSecondsChanged(remainingSeconds - 1)
- else -> {}
- }
- }
- }
-
companion object {
private const val SET_TIMER_TEXT = 1
private const val ANIMATION_DURATION_MS = 800L