Loading src/com/android/customization/picker/clock/ui/binder/ClockCarouselViewBinder.kt +1 −3 Original line number Diff line number Diff line Loading @@ -106,9 +106,7 @@ object ClockCarouselViewBinder { LifecycleEventObserver { source, event -> when (event) { Lifecycle.Event.ON_RESUME -> { clockViewFactory.registerTimeTicker(source) { !carouselView.isCarouselInTransition } clockViewFactory.registerTimeTicker(source) } Lifecycle.Event.ON_PAUSE -> { clockViewFactory.unregisterTimeTicker(source) Loading src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt +0 −6 Original line number Diff line number Diff line Loading @@ -36,8 +36,6 @@ class ClockCarouselView( attrs, ) { var isCarouselInTransition = false val carousel: Carousel private val motionLayout: MotionLayout private lateinit var adapter: ClockCarouselAdapter Loading Loading @@ -72,7 +70,6 @@ class ClockCarouselView( startId: Int, endId: Int ) { isCarouselInTransition = true val scalingDownClockId = adapter.clockIds[carousel.currentIndex] val scalingUpIdx = if (endId == R.id.next) (carousel.currentIndex + 1) % adapter.count() Loading Loading @@ -125,7 +122,6 @@ class ClockCarouselView( } override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) { isCarouselInTransition = false setCardAnimationState(currentId == R.id.start) } Loading Loading @@ -197,8 +193,6 @@ class ClockCarouselView( clockHostView.removeAllViews() val clockView = onGetClockController(clockIds[index]).largeClock.view // Making sure the large clock tick to the correct time onGetClockController(clockIds[index]).largeClock.events.onTimeTick() // The clock view might still be attached to an existing parent. Detach before adding to // another parent. (clockView.parent as? ViewGroup)?.removeView(clockView) Loading src/com/android/customization/picker/clock/ui/view/ClockViewFactory.kt +1 −9 Original line number Diff line number Diff line Loading @@ -67,21 +67,13 @@ class ClockViewFactory( } fun registerTimeTicker(owner: LifecycleOwner) { registerTimeTicker(owner, null) } fun registerTimeTicker(owner: LifecycleOwner, shouldTimeTick: (() -> Boolean)?) { val hashCode = owner.hashCode() if (timeTickListeners.keys.contains(hashCode)) { return } timeTickListeners[hashCode] = TimeTicker.registerNewReceiver(activity.applicationContext) { if (shouldTimeTick == null || shouldTimeTick()) { onTimeTick() } } TimeTicker.registerNewReceiver(activity.applicationContext) { onTimeTick() } } private fun onTimeTick() { Loading Loading
src/com/android/customization/picker/clock/ui/binder/ClockCarouselViewBinder.kt +1 −3 Original line number Diff line number Diff line Loading @@ -106,9 +106,7 @@ object ClockCarouselViewBinder { LifecycleEventObserver { source, event -> when (event) { Lifecycle.Event.ON_RESUME -> { clockViewFactory.registerTimeTicker(source) { !carouselView.isCarouselInTransition } clockViewFactory.registerTimeTicker(source) } Lifecycle.Event.ON_PAUSE -> { clockViewFactory.unregisterTimeTicker(source) Loading
src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt +0 −6 Original line number Diff line number Diff line Loading @@ -36,8 +36,6 @@ class ClockCarouselView( attrs, ) { var isCarouselInTransition = false val carousel: Carousel private val motionLayout: MotionLayout private lateinit var adapter: ClockCarouselAdapter Loading Loading @@ -72,7 +70,6 @@ class ClockCarouselView( startId: Int, endId: Int ) { isCarouselInTransition = true val scalingDownClockId = adapter.clockIds[carousel.currentIndex] val scalingUpIdx = if (endId == R.id.next) (carousel.currentIndex + 1) % adapter.count() Loading Loading @@ -125,7 +122,6 @@ class ClockCarouselView( } override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) { isCarouselInTransition = false setCardAnimationState(currentId == R.id.start) } Loading Loading @@ -197,8 +193,6 @@ class ClockCarouselView( clockHostView.removeAllViews() val clockView = onGetClockController(clockIds[index]).largeClock.view // Making sure the large clock tick to the correct time onGetClockController(clockIds[index]).largeClock.events.onTimeTick() // The clock view might still be attached to an existing parent. Detach before adding to // another parent. (clockView.parent as? ViewGroup)?.removeView(clockView) Loading
src/com/android/customization/picker/clock/ui/view/ClockViewFactory.kt +1 −9 Original line number Diff line number Diff line Loading @@ -67,21 +67,13 @@ class ClockViewFactory( } fun registerTimeTicker(owner: LifecycleOwner) { registerTimeTicker(owner, null) } fun registerTimeTicker(owner: LifecycleOwner, shouldTimeTick: (() -> Boolean)?) { val hashCode = owner.hashCode() if (timeTickListeners.keys.contains(hashCode)) { return } timeTickListeners[hashCode] = TimeTicker.registerNewReceiver(activity.applicationContext) { if (shouldTimeTick == null || shouldTimeTick()) { onTimeTick() } } TimeTicker.registerNewReceiver(activity.applicationContext) { onTimeTick() } } private fun onTimeTick() { Loading