fix: GroupPagerAdapter crash

This commit is contained in:
arm64v8a 2023-05-10 11:09:46 +09:00
parent 1b15199ee2
commit 2c6bfc1e51

View File

@ -886,16 +886,18 @@ class ConfigurationFragment @JvmOverloads constructor(
}
}
val runFunc = if (now) requireActivity()::runOnUiThread else groupPager::post
runFunc {
groupList = newGroupList
notifyDataSetChanged()
if (set) groupPager.setCurrentItem(selectedGroupIndex, false)
val hideTab = groupList.size < 2
tabLayout.isGone = hideTab
toolbar.elevation = if (hideTab) 0F else dp2px(4).toFloat()
if (!select) {
groupPager.registerOnPageChangeCallback(updateSelectedCallback)
val runFunc = if (now) activity?.let { it::runOnUiThread } else groupPager::post
if (runFunc != null) {
runFunc {
groupList = newGroupList
notifyDataSetChanged()
if (set) groupPager.setCurrentItem(selectedGroupIndex, false)
val hideTab = groupList.size < 2
tabLayout.isGone = hideTab
toolbar.elevation = if (hideTab) 0F else dp2px(4).toFloat()
if (!select) {
groupPager.registerOnPageChangeCallback(updateSelectedCallback)
}
}
}
}