From 8843a4a00645333f00a168b7b06532c3d55f8dc2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 17 Dec 2017 11:46:41 +0100 Subject: [PATCH] handle onPageSelected called twice on every page change --- .../gallery/activities/ViewPagerActivity.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 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 a551e96ff..79de936e8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -860,11 +860,14 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View if (view_pager.offscreenPageLimit == 1) { view_pager.offscreenPageLimit = 2 } - mPos = position - updateActionbarTitle() - mRotationDegrees = 0f - supportInvalidateOptionsMenu() - scheduleSwipe() + + if (mPos != position) { + mPos = position + updateActionbarTitle() + mRotationDegrees = 0f + supportInvalidateOptionsMenu() + scheduleSwipe() + } } override fun onPageScrollStateChanged(state: Int) {