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 <i@xzr.moe> Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com> Reviewed-on: https://review.statixos.com/c/android_packages_apps_Statix_ThemePicker/+/7728 Tested-by: Anay Wadhera <anay1018@gmail.com> Reviewed-by: Sourajit Karmakar <sourajit@live.com>
This commit is contained in:
parent
ebee0b6e71
commit
de4619e5c0
|
@ -101,9 +101,6 @@ class ColorSectionController(
|
|||
.inflate(R.layout.color_section_view, null as ViewGroup?) as ColorSectionView
|
||||
mColorViewPager = mColorSectionView!!.requireViewById<ViewPager2>(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()
|
||||
|
|
Loading…
Reference in New Issue