From af36fd45ad56a93350756cd751457c7d159a7809 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 21 Jun 2019 12:16:38 +0200 Subject: [PATCH] properly handle instant slideshow transition without animations --- .../gallery/pro/activities/ViewPagerActivity.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 361cbc326..285277d44 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -411,6 +411,16 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } + private fun goToNextMedium(forward: Boolean) { + val oldPosition = view_pager.currentItem + val newPosition = if (forward) oldPosition + 1 else oldPosition - 1 + if (newPosition == -1 || newPosition > view_pager.adapter!!.count - 1) { + slideshowEnded(forward) + } else { + view_pager.setCurrentItem(newPosition, false) + } + } + private fun animatePagerTransition(forward: Boolean) { val oldPosition = view_pager.currentItem val animator = ValueAnimator.ofInt(0, view_pager.width) @@ -506,7 +516,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun swipeToNextMedium() { - animatePagerTransition(!mSlideshowMoveBackwards) + if (config.slideshowAnimation == SLIDESHOW_ANIMATION_NONE) { + goToNextMedium(!mSlideshowMoveBackwards) + } else { + animatePagerTransition(!mSlideshowMoveBackwards) + } } private fun getMediaForSlideshow(): Boolean {