From de4619e5c0cfedfb7337c3cb7fae6131a2b642c2 Mon Sep 17 00:00:00 2001 From: LibXZR Date: Fri, 6 May 2022 23:24:13 +0800 Subject: [PATCH] ThemePicker: Defer color section adapter binding We need to make sure color options are fully initialized before setting up selectors. This fixes the race, which lead to the disappearance of color selectors, between loading color options and binding viewholders. Change-Id: Icdab4d1225862dd8c81db3655be89346a29c8122 Signed-off-by: LibXZR Signed-off-by: Adithya R Reviewed-on: https://review.statixos.com/c/android_packages_apps_Statix_ThemePicker/+/7728 Tested-by: Anay Wadhera Reviewed-by: Sourajit Karmakar --- .../customization/model/color/ColorSectionController.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/com/statix/android/customization/model/color/ColorSectionController.kt b/src/com/statix/android/customization/model/color/ColorSectionController.kt index c3d91ef..2ec43f8 100644 --- a/src/com/statix/android/customization/model/color/ColorSectionController.kt +++ b/src/com/statix/android/customization/model/color/ColorSectionController.kt @@ -101,9 +101,6 @@ class ColorSectionController( .inflate(R.layout.color_section_view, null as ViewGroup?) as ColorSectionView mColorViewPager = mColorSectionView!!.requireViewById(R.id.color_view_pager) mTabLayout = mColorSectionView!!.requireViewById(R.id.separated_tabs) - if (mColorViewPager.adapter == null) { - mColorViewPager.setAdapter(mColorSectionAdapter) - } mTabLayout!!.setViewPager(mColorViewPager) mWallpaperColorsViewModel.homeWallpaperColors.observe(mLifecycleOwner) { mHomeWallpaperColors = it @@ -176,6 +173,8 @@ class ColorSectionController( } mSelectedColor = colorOption mColorViewPager.post { + if (mColorViewPager.adapter == null) + mColorViewPager.setAdapter(mColorSectionAdapter) mColorViewPager.adapter?.notifyItemChanged(0) if (mTabLayout != null && mTabLayout!!.tabCount == 0) { val newTab = mTabLayout!!.newTab()