Fix issue with sort not working after rotating device

This commit is contained in:
Ensar Sarajčić 2023-08-17 16:54:56 +02:00
parent 8ab9448f54
commit 68de0e8d79
1 changed files with 8 additions and 2 deletions

View File

@ -15,8 +15,14 @@ class ViewPagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
private val fragments = HashMap<Int, Fragment>()
override fun getItem(position: Int): Fragment {
val fragment = getFragment(position)
fragments[position] = fragment
return getFragment(position)
}
override fun instantiateItem(container: ViewGroup, position: Int): Any {
val fragment = super.instantiateItem(container, position)
if (fragment is Fragment) {
fragments[position] = fragment
}
return fragment
}