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() {
|
private fun reloadViewPager() {
|
||||||
val adapter = view_pager.adapter as MyPagerAdapter
|
|
||||||
val curPos = view_pager.currentItem
|
|
||||||
mMedia = getMedia()
|
mMedia = getMedia()
|
||||||
|
|
||||||
if (isDirEmpty())
|
if (isDirEmpty())
|
||||||
return
|
return
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
adapter.updateItems(mMedia!!)
|
updatePagerItems()
|
||||||
|
|
||||||
val newPos = Math.min(curPos, adapter.count)
|
|
||||||
view_pager.currentItem = newPos
|
|
||||||
updateActionbarTitle()
|
|
||||||
mPos = newPos
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,10 +55,4 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m
|
||||||
(-1..1).map { mFragments[pos + it] }
|
(-1..1).map { mFragments[pos + it] }
|
||||||
.forEach { it?.updateItem() }
|
.forEach { it?.updateItem() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateItems(newPaths: List<Medium>) {
|
|
||||||
media.clear()
|
|
||||||
media.addAll(newPaths)
|
|
||||||
notifyDataSetChanged()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue