mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
load 1 image per side initially at viewpager for faster loading
This commit is contained in:
parent
3a98da85fe
commit
c0bb740c87
2 changed files with 3 additions and 2 deletions
|
@ -214,7 +214,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, mMedia)
|
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, mMedia)
|
||||||
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 {
|
||||||
offscreenPageLimit = 2
|
|
||||||
adapter = pagerAdapter
|
adapter = pagerAdapter
|
||||||
currentItem = mPos
|
currentItem = mPos
|
||||||
addOnPageChangeListener(this@ViewPagerActivity)
|
addOnPageChangeListener(this@ViewPagerActivity)
|
||||||
|
@ -503,6 +502,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
|
if (view_pager.offscreenPageLimit == 1) {
|
||||||
|
view_pager.offscreenPageLimit = 2
|
||||||
|
}
|
||||||
mPos = position
|
mPos = position
|
||||||
updateActionbarTitle()
|
updateActionbarTitle()
|
||||||
mRotationDegrees = 0f
|
mRotationDegrees = 0f
|
||||||
|
|
|
@ -215,7 +215,6 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
override fun onImageLoadError(e: Exception?) {
|
override fun onImageLoadError(e: Exception?) {
|
||||||
background = ColorDrawable(Color.TRANSPARENT)
|
background = ColorDrawable(Color.TRANSPARENT)
|
||||||
|
|
||||||
beGone()
|
beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue