Merge pull request #495 from esensar/fix/sort-rotation

Fix issue with sort not working after rotating device
This commit is contained in:
Tibor Kaputa 2023-08-17 17:09:07 +02:00 committed by GitHub
commit c88b9af155
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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
}