Resolve NPE when user updates display size
The cause of this crash was when one on the emitters were triggerring a coroutine to reposition
the colors RV at a time when the RV was not instantiated.
Fix: 280939729
Test: manual
Change-Id: If89baa7febe5b57d509f1033ba5030b8af7683b9
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 d8c5dce..053ac55 100644
--- a/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
+++ b/src/com/android/customization/picker/clock/ui/binder/ClockSettingsBinder.kt
@@ -159,11 +159,12 @@
if (selectedPosition != -1) {
val colorOptionContainerListView: LinearLayout =
view.requireViewById(R.id.color_options)
+
val selectedView =
- colorOptionContainerListView.requireViewById<View>(
+ colorOptionContainerListView.findViewById<View>(
COLOR_PICKER_ITEM_PREFIX_ID + selectedPosition
)
- selectedView.parent.requestChildFocus(selectedView, selectedView)
+ selectedView?.parent?.requestChildFocus(selectedView, selectedView)
}
}
}