[TP] Fix carousel missing
When coming back from a secondary screen, e.g. clock settings,
shortcuts, the clock carousel is missing. This is to fix it.
Test: tested that the carousel is shown when back from a secondary
screen
Bug: 271106023
Change-Id: Ifd1adf86a473efaaa5c11091ff3f60e94734a08e
diff --git a/src/com/android/customization/picker/clock/ui/binder/ClockCarouselViewBinder.kt b/src/com/android/customization/picker/clock/ui/binder/ClockCarouselViewBinder.kt
index 48b37ba..6c72a5b 100644
--- a/src/com/android/customization/picker/clock/ui/binder/ClockCarouselViewBinder.kt
+++ b/src/com/android/customization/picker/clock/ui/binder/ClockCarouselViewBinder.kt
@@ -40,7 +40,7 @@
@JvmStatic
fun bind(
- view: ClockCarouselView,
+ carouselView: ClockCarouselView,
singleClockView: ViewGroup,
viewModel: ClockCarouselViewModel,
clockViewFactory: (clockId: String) -> View,
@@ -50,11 +50,11 @@
singleClockView.requireViewById<FrameLayout>(R.id.single_clock_host_view)
lifecycleOwner.lifecycleScope.launch {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
- launch { viewModel.isCarouselVisible.collect { view.isVisible = it } }
+ launch { viewModel.isCarouselVisible.collect { carouselView.isVisible = it } }
launch {
viewModel.allClockIds.collect { allClockIds ->
- view.setUpClockCarouselView(
+ carouselView.setUpClockCarouselView(
clockIds = allClockIds,
onGetClockPreview = clockViewFactory,
onClockSelected = { clockId -> viewModel.setSelectedClock(clockId) },
@@ -64,11 +64,13 @@
launch {
viewModel.selectedIndex.collect { selectedIndex ->
- view.setSelectedClockIndex(selectedIndex)
+ carouselView.setSelectedClockIndex(selectedIndex)
}
}
- launch { viewModel.isSingleClockViewVisible.collect { view.isVisible = it } }
+ launch {
+ viewModel.isSingleClockViewVisible.collect { singleClockView.isVisible = it }
+ }
launch {
viewModel.clockId.collect { clockId ->
diff --git a/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt b/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
index 2ca1f3b..0b197b4 100644
--- a/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
+++ b/src/com/android/customization/picker/preview/ui/section/PreviewWithClockCarouselSectionController.kt
@@ -76,7 +76,7 @@
lifecycleOwner.lifecycleScope.launch {
clockCarouselBinding =
ClockCarouselViewBinder.bind(
- view = carouselView,
+ carouselView = carouselView,
singleClockView = singleClockView,
viewModel = clockCarouselViewModel,
clockViewFactory = { clockId -> clockViewFactory.getView(clockId) },