mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
use the initialization function for reloading the viewpager
This commit is contained in:
parent
df5dc70f61
commit
6f60d3fcfd
2 changed files with 1 additions and 15 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue