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