convert mMedia to a mutable list before providing to MyPagerAdapter

This commit is contained in:
tibbi 2017-07-09 13:58:08 +02:00
parent a355b0a7b8
commit ce41e5b7b9
2 changed files with 3 additions and 3 deletions

View file

@ -228,7 +228,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
} }
private fun updatePagerItems() { private fun updatePagerItems() {
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, mMedia) val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, mMedia.toMutableList())
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !isDestroyed) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !isDestroyed) {
view_pager.apply { view_pager.apply {
adapter = pagerAdapter adapter = pagerAdapter

View file

@ -42,9 +42,9 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m
return fragment return fragment
} }
override fun destroyItem(container: ViewGroup?, position: Int, `object`: Any?) { override fun destroyItem(container: ViewGroup?, position: Int, any: Any?) {
mFragments.remove(position) mFragments.remove(position)
super.destroyItem(container, position, `object`) super.destroyItem(container, position, any)
} }
fun getCurrentFragment(position: Int) = mFragments.get(position) fun getCurrentFragment(position: Int) = mFragments.get(position)