mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-02-19 05:20:36 +01:00
use the initialization function for reloading the viewpager
This commit is contained in:
parent
df5dc70f61
commit
6f60d3fcfd
@ -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…
x
Reference in New Issue
Block a user