Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt +30 −23 Original line number Diff line number Diff line Loading @@ -48,8 +48,6 @@ import kotlinx.coroutines.flow.map object KeyguardClockViewBinder { private val TAG = KeyguardClockViewBinder::class.simpleName!! // When changing to new clock, we need to remove old clock views from burnInLayer private var lastClock: ClockController? = null @JvmStatic fun bind( Loading @@ -72,10 +70,20 @@ object KeyguardClockViewBinder { disposables += keyguardRootView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { // When changing to new clock, we need to remove old views from burnInLayer var lastClock: ClockController? = null launch { if (!MigrateClocksToBlueprint.isEnabled) return@launch viewModel.currentClock.collect { currentClock -> cleanupClockViews(currentClock, keyguardRootView, viewModel.burnInLayer) if (lastClock != currentClock) { cleanupClockViews( lastClock, keyguardRootView, viewModel.burnInLayer, ) lastClock = currentClock } addClockViews(currentClock, keyguardRootView) updateBurnInLayer( keyguardRootView, Loading @@ -85,6 +93,10 @@ object KeyguardClockViewBinder { applyConstraints(clockSection, keyguardRootView, true) } } .invokeOnCompletion { cleanupClockViews(lastClock, keyguardRootView, viewModel.burnInLayer) lastClock = null } launch { if (!MigrateClocksToBlueprint.isEnabled) return@launch Loading Loading @@ -185,23 +197,18 @@ object KeyguardClockViewBinder { viewModel.burnInLayer?.updatePostLayout(keyguardRootView) } private fun cleanupClockViews( currentClock: ClockController?, fun cleanupClockViews( lastClock: ClockController?, rootView: ConstraintLayout, burnInLayer: Layer?, ) { if (lastClock == currentClock) { return } lastClock?.let { clock -> clock.smallClock.layout.views.forEach { lastClock?.run { smallClock.layout.views.forEach { burnInLayer?.removeView(it) rootView.removeView(it) } clock.largeClock.layout.views.forEach { rootView.removeView(it) } largeClock.layout.views.forEach { rootView.removeView(it) } } lastClock = currentClock } @VisibleForTesting Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt +1 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ object KeyguardPreviewClockViewBinder { ) } } lastClock = null } } } Loading Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt +30 −23 Original line number Diff line number Diff line Loading @@ -48,8 +48,6 @@ import kotlinx.coroutines.flow.map object KeyguardClockViewBinder { private val TAG = KeyguardClockViewBinder::class.simpleName!! // When changing to new clock, we need to remove old clock views from burnInLayer private var lastClock: ClockController? = null @JvmStatic fun bind( Loading @@ -72,10 +70,20 @@ object KeyguardClockViewBinder { disposables += keyguardRootView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { // When changing to new clock, we need to remove old views from burnInLayer var lastClock: ClockController? = null launch { if (!MigrateClocksToBlueprint.isEnabled) return@launch viewModel.currentClock.collect { currentClock -> cleanupClockViews(currentClock, keyguardRootView, viewModel.burnInLayer) if (lastClock != currentClock) { cleanupClockViews( lastClock, keyguardRootView, viewModel.burnInLayer, ) lastClock = currentClock } addClockViews(currentClock, keyguardRootView) updateBurnInLayer( keyguardRootView, Loading @@ -85,6 +93,10 @@ object KeyguardClockViewBinder { applyConstraints(clockSection, keyguardRootView, true) } } .invokeOnCompletion { cleanupClockViews(lastClock, keyguardRootView, viewModel.burnInLayer) lastClock = null } launch { if (!MigrateClocksToBlueprint.isEnabled) return@launch Loading Loading @@ -185,23 +197,18 @@ object KeyguardClockViewBinder { viewModel.burnInLayer?.updatePostLayout(keyguardRootView) } private fun cleanupClockViews( currentClock: ClockController?, fun cleanupClockViews( lastClock: ClockController?, rootView: ConstraintLayout, burnInLayer: Layer?, ) { if (lastClock == currentClock) { return } lastClock?.let { clock -> clock.smallClock.layout.views.forEach { lastClock?.run { smallClock.layout.views.forEach { burnInLayer?.removeView(it) rootView.removeView(it) } clock.largeClock.layout.views.forEach { rootView.removeView(it) } largeClock.layout.views.forEach { rootView.removeView(it) } } lastClock = currentClock } @VisibleForTesting Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt +1 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ object KeyguardPreviewClockViewBinder { ) } } lastClock = null } } } Loading