Fix stuck UI after rotation (#275)

This commit is contained in:
Jerry 2024-10-17 13:43:15 +02:00
parent 5054b37a96
commit 817b1ddb32

View file

@ -33,7 +33,6 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m
}
fragment.arguments = bundle
fragment.listener = activity
return fragment
}
@ -41,6 +40,10 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m
override fun instantiateItem(container: ViewGroup, position: Int): Any {
val fragment = super.instantiateItem(container, position) as ViewPagerFragment
// getItem() might not be called if the activity is recreated, so the listener must be set here
fragment.listener = activity
fragments[position] = fragment
return fragment
}