filter out videos, or shuffle the media at slideshow when appropriate

This commit is contained in:
tibbi 2017-08-05 14:52:42 +02:00
parent 3757616a47
commit 74e6c69473
18 changed files with 54 additions and 12 deletions

View file

@ -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<Medium>) {
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<File>(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<Medium>): Int {
mPos = 0
var i = 0
for (medium in mMedia) {
for (medium in items) {
if (medium.path == mPath) {
return i
}

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">Zobrazit skryté média</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">Versteckte Ordner zeigen</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">Mostrar carpetas ocultas</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">Afficher les dossiers cachés</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">Show hidden media</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">Mostra cartelle nascoste</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">非表示フォルダーを表示</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">Pokazuj ukryte foldery</string>

View file

@ -88,6 +88,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">Mostrar pastas ocultas</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">Mostrar pastas ocultas</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">Показать скрытые папки</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Používať miznúce animácie</string>
<string name="move_backwards">Ísť opačným smerom</string>
<string name="slideshow_ended">Prezentácia skončila</string>
<string name="no_media_for_slideshow">Pre prezentáciu sa nenašli žiadne vhodné súbory</string>
<!-- Settings -->
<string name="show_hidden_media">Zobraziť skryté médiá</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">Visa dolda mappar</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">Gizli klasörleri göster</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">显示所有</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">秀出隱藏資料夾</string>

View file

@ -87,6 +87,7 @@
<string name="use_fade">Use fade animations</string>
<string name="move_backwards">Move backwards</string>
<string name="slideshow_ended">The slideshow ended</string>
<string name="no_media_for_slideshow">No media for the slideshow have been found</string>
<!-- Settings -->
<string name="show_hidden_media">Show hidden media</string>