From ff4a7d4bb4b5cbf4c0ecfbe2ca1c7f9fcec661ea Mon Sep 17 00:00:00 2001 From: Naveen Date: Sat, 24 Sep 2022 01:20:08 +0530 Subject: [PATCH] Use `mSlideShowMedia` even after stopping random slideshow As before, random order doesn't go away by itself until activity is restarted normally (without slideshow) --- .../gallery/pro/activities/ViewPagerActivity.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 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 81c108f08..04680c25c 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 @@ -80,6 +80,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private var mSlideshowMoveBackwards = false private var mSlideshowMedia = mutableListOf() private var mAreSlideShowMediaVisible = false + private var mRandomSlideshowStopped = false private var mIsOrientationLocked = false @@ -505,6 +506,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } hideSystemUI(true) + mRandomSlideshowStopped = false mSlideshowInterval = config.slideshowInterval mSlideshowMoveBackwards = config.slideshowMoveBackwards mIsSlideshowActive = true @@ -600,6 +602,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View mSlideshowHandler.removeCallbacksAndMessages(null) window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) mAreSlideShowMediaVisible = false + + if (config.slideshowRandomOrder) { + mRandomSlideshowStopped = true + } } } @@ -1429,8 +1435,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun updateActionbarTitle() { runOnUiThread { - if (mPos < getCurrentMedia().size) { - medium_viewer_toolbar.title = getCurrentMedia()[mPos].path.getFilenameFromPath() + val medium = getCurrentMedium() + if (medium != null) { + medium_viewer_toolbar.title = medium.path.getFilenameFromPath() } } } @@ -1443,7 +1450,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } - private fun getCurrentMedia() = if (mAreSlideShowMediaVisible) mSlideshowMedia else mMediaFiles + private fun getCurrentMedia() = if (mAreSlideShowMediaVisible || mRandomSlideshowStopped) mSlideshowMedia else mMediaFiles private fun getCurrentPath() = getCurrentMedium()?.path ?: ""