use the initialization function for reloading the viewpager

This commit is contained in:
tibbi 2016-12-04 19:46:11 +01:00
parent df5dc70f61
commit 6f60d3fcfd
2 changed files with 1 additions and 15 deletions

View file

@ -237,20 +237,12 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
}
private fun reloadViewPager() {
val adapter = view_pager.adapter as MyPagerAdapter
val curPos = view_pager.currentItem
mMedia = getMedia()
if (isDirEmpty())
return
runOnUiThread {
adapter.updateItems(mMedia!!)
val newPos = Math.min(curPos, adapter.count)
view_pager.currentItem = newPos
updateActionbarTitle()
mPos = newPos
updatePagerItems()
}
}

View file

@ -55,10 +55,4 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m
(-1..1).map { mFragments[pos + it] }
.forEach { it?.updateItem() }
}
fun updateItems(newPaths: List<Medium>) {
media.clear()
media.addAll(newPaths)
notifyDataSetChanged()
}
}