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 f8921e581..d22d0d7e4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -242,8 +242,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View return true } - private fun updatePagerItems() { - val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, mMedia.toMutableList()) + private fun updatePagerItems(media: MutableList) { + val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, media) if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !isDestroyed) { view_pager.apply { adapter = pagerAdapter @@ -261,12 +261,14 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun startSlideshow() { - hideSystemUI() - mSlideshowInterval = config.slideshowInterval - mSlideshowMoveBackwards = config.slideshowMoveBackwards - mIsSlideshowActive = true - scheduleSwipe() - window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) + if (getMediaForSlideshow()) { + hideSystemUI() + mSlideshowInterval = config.slideshowInterval + mSlideshowMoveBackwards = config.slideshowMoveBackwards + mIsSlideshowActive = true + scheduleSwipe() + window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) + } } private fun stopSlideshow() { @@ -294,6 +296,29 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } + private fun getMediaForSlideshow(): Boolean { + var slideshowMedia = mMedia.toMutableList() + if (!config.slideshowIncludeVideos) { + slideshowMedia = slideshowMedia.filter { it.isImage() || it.isGif() } as MutableList + } + + if (config.slideshowRandomOrder) { + Collections.shuffle(slideshowMedia) + mPos = 0 + } else { + mPath = getCurrentPath() + mPos = getPositionInList(slideshowMedia) + } + + return if (slideshowMedia.isEmpty()) { + toast(R.string.no_media_for_slideshow) + false + } else { + updatePagerItems(slideshowMedia) + true + } + } + private fun copyMoveTo(isCopyOperation: Boolean) { val files = ArrayList(1).apply { add(getCurrentFile()) } tryCopyMoveFilesTo(files, isCopyOperation) { @@ -527,21 +552,21 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View mPrevHashcode = media.hashCode() mMedia = media if (mPos == -1) { - mPos = getProperPosition() + mPos = getPositionInList(media) } else { mPos = Math.min(mPos, mMedia.size - 1) } updateActionbarTitle() - updatePagerItems() + updatePagerItems(mMedia.toMutableList()) invalidateOptionsMenu() checkOrientation() } - private fun getProperPosition(): Int { + private fun getPositionInList(items: MutableList): Int { mPos = 0 var i = 0 - for (medium in mMedia) { + for (medium in items) { if (medium.path == mPath) { return i } diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 1493a9c34..b8d448371 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found Zobrazit skryté média diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 040131968..e6ff1b2c1 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found Versteckte Ordner zeigen diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index a6eb944ae..209da01f5 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found Mostrar carpetas ocultas diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index d993abc15..1ccc71678 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found Afficher les dossiers cachés diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 720943b49..c4cd345d5 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found Show hidden media diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 904972ae8..a5d45c2ca 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found Mostra cartelle nascoste diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index a7c0bbb20..4091adc4a 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found 非表示フォルダーを表示 diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 05867cb6d..c54a4e2ec 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found Pokazuj ukryte foldery diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index b57ea381a..e54551925 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -88,6 +88,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found Mostrar pastas ocultas diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 077c17e7e..d4a248432 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found Mostrar pastas ocultas diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 15eb352d2..581c31ace 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found Показать скрытые папки diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 3b3d198ba..b2f2f7a72 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -87,6 +87,7 @@ Používať miznúce animácie Ísť opačným smerom Prezentácia skončila + Pre prezentáciu sa nenašli žiadne vhodné súbory Zobraziť skryté médiá diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 4d9d2e355..67d51e72a 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found Visa dolda mappar diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 689996d7f..fba714c2a 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found Gizli klasörleri göster diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 65ee6ea6e..ed7d6b9ab 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found 显示所有 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 3490d4708..d036415d4 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found 秀出隱藏資料夾 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 624a33b7f..8ad387a9b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -87,6 +87,7 @@ Use fade animations Move backwards The slideshow ended + No media for the slideshow have been found Show hidden media