mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
do the hidden file filtering right inside getCachedMedia
This commit is contained in:
parent
d479baa625
commit
a90f48889d
2 changed files with 10 additions and 10 deletions
|
@ -456,16 +456,10 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
mIsGettingMedia = true
|
||||
if (!mLoadedInitialPhotos) {
|
||||
getCachedMedia(mPath) {
|
||||
val shouldShowHidden = config.shouldShowHidden
|
||||
var media = it
|
||||
if (!shouldShowHidden) {
|
||||
media = media.filter { !it.name.startsWith('.') } as ArrayList<Medium>
|
||||
}
|
||||
|
||||
if (media.isEmpty()) {
|
||||
if (it.isEmpty()) {
|
||||
media_refresh_layout.isRefreshing = true
|
||||
} else {
|
||||
gotMedia(media, true)
|
||||
gotMedia(it, true)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -485,9 +479,10 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
deleteDirectoryIfEmpty()
|
||||
finish()
|
||||
true
|
||||
} else
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private fun tryToggleTemporarilyShowHidden() {
|
||||
if (config.temporarilyShowHidden) {
|
||||
|
|
|
@ -258,7 +258,12 @@ fun Context.getCachedMedia(path: String, callback: (ArrayList<Medium>) -> Unit)
|
|||
Thread {
|
||||
val mediumDao = galleryDB.MediumDao()
|
||||
val media = mediumDao.getMediaFromPath(path) as ArrayList<Medium>
|
||||
callback(media)
|
||||
val shouldShowHidden = config.shouldShowHidden
|
||||
var filteredMedia = media
|
||||
if (!shouldShowHidden) {
|
||||
filteredMedia = media.filter { !it.name.startsWith('.') } as ArrayList<Medium>
|
||||
}
|
||||
callback(filteredMedia)
|
||||
|
||||
media.filter { !File(it.path).exists() }.forEach {
|
||||
mediumDao.deleteMediumPath(it.path)
|
||||
|
|
Loading…
Reference in a new issue