Fix missing clock on clock setting screen
clockHostView tries to add clockView before removeAllView has finished.
Post adding clockView to the next round.
Flag: EXEMPT bugfix
Fixes: 396984345
Test: preview clock
Change-Id: I6fd30ab82e30da52a6926a4484baca412808a039
diff --git a/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt b/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
index 764c671..3d1e32f 100644
--- a/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
+++ b/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
@@ -207,10 +207,14 @@
ClockSize.DYNAMIC -> clockViewFactory.getLargeView(clockId)
ClockSize.SMALL -> clockViewFactory.getSmallView(clockId)
}
- // The clock view might still be attached to an existing parent.
- // Detach before adding to another parent.
- (clockView.parent as? ViewGroup)?.removeView(clockView)
- clockHostView.addView(clockView)
+
+ // Wait for previous removeAllViews to finish, and add the clockView
+ clockHostView.post {
+ // The clock view might still be attached to an existing parent.
+ // Detach before adding to another parent.
+ (clockView.parent as? ViewGroup)?.removeView(clockView)
+ clockHostView.addView(clockView)
+ }
when (size) {
ClockSize.DYNAMIC -> {