From ec6e532c526da9a2bb2431d5712436c59ee6c6f1 Mon Sep 17 00:00:00 2001 From: darthpaul Date: Fri, 20 May 2022 00:02:33 +0100 Subject: [PATCH] fix: position returning to 0 - call onPageSelected(0) if the media.size == 1 --- .../gallery/pro/activities/ViewPagerActivity.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 72b23be1e..780ce879b 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 @@ -1140,6 +1140,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } + if (media.size == 1) { + onPageSelected(0) + } + movePathsInRecycleBin(arrayListOf(path)) { if (it) { tryDeleteFileDirItem(fileDirItem, false, false) { @@ -1173,6 +1177,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } + if (media.size == 1) { + onPageSelected(0) + } + tryDeleteFileDirItem(fileDirItem, false, true) { mIgnoredPaths.remove(fileDirItem.path) if (media.isEmpty()) { @@ -1413,11 +1421,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun getCurrentPath() = getCurrentMedium()?.path ?: "" - override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { - if (position == 0) { - onPageSelected(0) - } - } + override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {} override fun onPageSelected(position: Int) { if (mPos != position) {