filter out videos, or shuffle the media at slideshow when appropriate
This commit is contained in:
parent
3757616a47
commit
74e6c69473
|
@ -242,8 +242,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updatePagerItems() {
|
private fun updatePagerItems(media: MutableList<Medium>) {
|
||||||
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, mMedia.toMutableList())
|
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, media)
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !isDestroyed) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1 || !isDestroyed) {
|
||||||
view_pager.apply {
|
view_pager.apply {
|
||||||
adapter = pagerAdapter
|
adapter = pagerAdapter
|
||||||
|
@ -261,12 +261,14 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startSlideshow() {
|
private fun startSlideshow() {
|
||||||
hideSystemUI()
|
if (getMediaForSlideshow()) {
|
||||||
mSlideshowInterval = config.slideshowInterval
|
hideSystemUI()
|
||||||
mSlideshowMoveBackwards = config.slideshowMoveBackwards
|
mSlideshowInterval = config.slideshowInterval
|
||||||
mIsSlideshowActive = true
|
mSlideshowMoveBackwards = config.slideshowMoveBackwards
|
||||||
scheduleSwipe()
|
mIsSlideshowActive = true
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
scheduleSwipe()
|
||||||
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stopSlideshow() {
|
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) {
|
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||||
val files = ArrayList<File>(1).apply { add(getCurrentFile()) }
|
val files = ArrayList<File>(1).apply { add(getCurrentFile()) }
|
||||||
tryCopyMoveFilesTo(files, isCopyOperation) {
|
tryCopyMoveFilesTo(files, isCopyOperation) {
|
||||||
|
@ -527,21 +552,21 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
mPrevHashcode = media.hashCode()
|
mPrevHashcode = media.hashCode()
|
||||||
mMedia = media
|
mMedia = media
|
||||||
if (mPos == -1) {
|
if (mPos == -1) {
|
||||||
mPos = getProperPosition()
|
mPos = getPositionInList(media)
|
||||||
} else {
|
} else {
|
||||||
mPos = Math.min(mPos, mMedia.size - 1)
|
mPos = Math.min(mPos, mMedia.size - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateActionbarTitle()
|
updateActionbarTitle()
|
||||||
updatePagerItems()
|
updatePagerItems(mMedia.toMutableList())
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
checkOrientation()
|
checkOrientation()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getProperPosition(): Int {
|
private fun getPositionInList(items: MutableList<Medium>): Int {
|
||||||
mPos = 0
|
mPos = 0
|
||||||
var i = 0
|
var i = 0
|
||||||
for (medium in mMedia) {
|
for (medium in items) {
|
||||||
if (medium.path == mPath) {
|
if (medium.path == mPath) {
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">Zobrazit skryté média</string>
|
<string name="show_hidden_media">Zobrazit skryté média</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">Versteckte Ordner zeigen</string>
|
<string name="show_hidden_media">Versteckte Ordner zeigen</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">Mostrar carpetas ocultas</string>
|
<string name="show_hidden_media">Mostrar carpetas ocultas</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">Afficher les dossiers cachés</string>
|
<string name="show_hidden_media">Afficher les dossiers cachés</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">Show hidden media</string>
|
<string name="show_hidden_media">Show hidden media</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">Mostra cartelle nascoste</string>
|
<string name="show_hidden_media">Mostra cartelle nascoste</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">非表示フォルダーを表示</string>
|
<string name="show_hidden_media">非表示フォルダーを表示</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">Pokazuj ukryte foldery</string>
|
<string name="show_hidden_media">Pokazuj ukryte foldery</string>
|
||||||
|
|
|
@ -88,6 +88,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">Mostrar pastas ocultas</string>
|
<string name="show_hidden_media">Mostrar pastas ocultas</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">Mostrar pastas ocultas</string>
|
<string name="show_hidden_media">Mostrar pastas ocultas</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">Показать скрытые папки</string>
|
<string name="show_hidden_media">Показать скрытые папки</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Používať miznúce animácie</string>
|
<string name="use_fade">Používať miznúce animácie</string>
|
||||||
<string name="move_backwards">Ísť opačným smerom</string>
|
<string name="move_backwards">Ísť opačným smerom</string>
|
||||||
<string name="slideshow_ended">Prezentácia skončila</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">Zobraziť skryté médiá</string>
|
<string name="show_hidden_media">Zobraziť skryté médiá</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">Visa dolda mappar</string>
|
<string name="show_hidden_media">Visa dolda mappar</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">Gizli klasörleri göster</string>
|
<string name="show_hidden_media">Gizli klasörleri göster</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">显示所有</string>
|
<string name="show_hidden_media">显示所有</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">秀出隱藏資料夾</string>
|
<string name="show_hidden_media">秀出隱藏資料夾</string>
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
<string name="move_backwards">Move backwards</string>
|
<string name="move_backwards">Move backwards</string>
|
||||||
<string name="slideshow_ended">The slideshow ended</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 -->
|
<!-- Settings -->
|
||||||
<string name="show_hidden_media">Show hidden media</string>
|
<string name="show_hidden_media">Show hidden media</string>
|
||||||
|
|
Loading…
Reference in New Issue