load 1 image per side initially at viewpager for faster loading

This commit is contained in:
tibbi 2017-05-20 19:27:54 +02:00
parent 3a98da85fe
commit c0bb740c87
2 changed files with 3 additions and 2 deletions

View file

@ -214,7 +214,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, mMedia)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !isDestroyed) {
view_pager.apply {
offscreenPageLimit = 2
adapter = pagerAdapter
currentItem = mPos
addOnPageChangeListener(this@ViewPagerActivity)
@ -503,6 +502,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
}
override fun onPageSelected(position: Int) {
if (view_pager.offscreenPageLimit == 1) {
view_pager.offscreenPageLimit = 2
}
mPos = position
updateActionbarTitle()
mRotationDegrees = 0f

View file

@ -215,7 +215,6 @@ class PhotoFragment : ViewPagerFragment() {
override fun onImageLoadError(e: Exception?) {
background = ColorDrawable(Color.TRANSPARENT)
beGone()
}