mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
Remove page change listener before changing adapter
This commit is contained in:
parent
ccb9b60a12
commit
e6039d07cb
1 changed files with 3 additions and 2 deletions
|
@ -462,11 +462,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
if (!isDestroyed) {
|
||||
pagerAdapter.shouldInitFragment = mPos < 5
|
||||
view_pager.apply {
|
||||
// must remove the listener before changing adapter, otherwise it might cause `mPos` to be set to 0
|
||||
removeOnPageChangeListener(this@ViewPagerActivity)
|
||||
adapter = pagerAdapter
|
||||
pagerAdapter.shouldInitFragment = true
|
||||
currentItem = mPos
|
||||
removeOnPageChangeListener(this@ViewPagerActivity)
|
||||
addOnPageChangeListener(this@ViewPagerActivity)
|
||||
currentItem = mPos
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue