diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 384af1343..7d167f334 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -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 - } - - if (media.isEmpty()) { + if (it.isEmpty()) { media_refresh_layout.isRefreshing = true } else { - gotMedia(media, true) + gotMedia(it, true) } } } else { @@ -485,8 +479,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { deleteDirectoryIfEmpty() finish() true - } else + } else { false + } } private fun tryToggleTemporarilyShowHidden() { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt index 74718a1f7..906c0f026 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt @@ -258,7 +258,12 @@ fun Context.getCachedMedia(path: String, callback: (ArrayList) -> Unit) Thread { val mediumDao = galleryDB.MediumDao() val media = mediumDao.getMediaFromPath(path) as ArrayList - callback(media) + val shouldShowHidden = config.shouldShowHidden + var filteredMedia = media + if (!shouldShowHidden) { + filteredMedia = media.filter { !it.name.startsWith('.') } as ArrayList + } + callback(filteredMedia) media.filter { !File(it.path).exists() }.forEach { mediumDao.deleteMediumPath(it.path)