From c0bb740c87120104981d1419622f8f472e5231ae Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 20 May 2017 19:27:54 +0200 Subject: [PATCH] load 1 image per side initially at viewpager for faster loading --- .../simplemobiletools/gallery/activities/ViewPagerActivity.kt | 4 +++- .../com/simplemobiletools/gallery/fragments/PhotoFragment.kt | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 0c13f4134..358f1e1ca 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -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 diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index 875ef6e1a..5664ed1f8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -215,7 +215,6 @@ class PhotoFragment : ViewPagerFragment() { override fun onImageLoadError(e: Exception?) { background = ColorDrawable(Color.TRANSPARENT) - beGone() }