mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-27 06:57:59 +01:00
make really sure that only the proper folders are shown at Show All Folders Content
This commit is contained in:
parent
af6121ec63
commit
c4ef4a69b9
4 changed files with 16 additions and 23 deletions
|
@ -481,6 +481,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
mCurrAsyncTask = GetMediaAsynctask(applicationContext, mPath, mIsGetImageIntent, mIsGetVideoIntent, mShowAll) {
|
||||
gotMedia(it)
|
||||
}
|
||||
|
||||
mCurrAsyncTask!!.execute()
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage
|
|||
return if (showAll) {
|
||||
val foldersToScan = mediaFetcher.getFoldersToScan()
|
||||
val media = ArrayList<Medium>()
|
||||
for (folder in foldersToScan) {
|
||||
val newMedia = mediaFetcher.getFilesFrom(folder, isPickImage, isPickVideo, sorting)
|
||||
foldersToScan.forEach {
|
||||
val newMedia = mediaFetcher.getFilesFrom(it, isPickImage, isPickVideo, sorting)
|
||||
media.addAll(newMedia)
|
||||
}
|
||||
|
||||
|
|
|
@ -302,36 +302,31 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly:
|
|||
fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImagesOnly: Boolean = false, callback: (ArrayList<Medium>) -> Unit) {
|
||||
Thread {
|
||||
val mediumDao = galleryDB.MediumDao()
|
||||
val media = (if (path == "/") mediumDao.getAll() else mediumDao.getMediaFromPath(path)) as ArrayList<Medium>
|
||||
val foldersToScan = if (path == "/") MediaFetcher(this).getFoldersToScan() else arrayListOf(path)
|
||||
var media = ArrayList<Medium>()
|
||||
val shouldShowHidden = config.shouldShowHidden
|
||||
var filteredMedia = media
|
||||
if (!shouldShowHidden) {
|
||||
filteredMedia = media.filter { !it.path.contains("/.") } as ArrayList<Medium>
|
||||
foldersToScan.forEach {
|
||||
val currMedia = mediumDao.getMediaFromPath(it)
|
||||
media.addAll(currMedia)
|
||||
}
|
||||
|
||||
if (path == "/") {
|
||||
val excludedFolders = config.excludedFolders
|
||||
filteredMedia = filteredMedia.filter {
|
||||
val mediumPath = it.path
|
||||
excludedFolders.none {
|
||||
mediumPath.startsWith(it, true)
|
||||
}
|
||||
} as ArrayList<Medium>
|
||||
if (!shouldShowHidden) {
|
||||
media = media.filter { !it.path.contains("/.") } as ArrayList<Medium>
|
||||
}
|
||||
|
||||
val filterMedia = config.filterMedia
|
||||
filteredMedia = (when {
|
||||
getVideosOnly -> filteredMedia.filter { it.type == TYPE_VIDEOS }
|
||||
getImagesOnly -> filteredMedia.filter { it.type == TYPE_IMAGES }
|
||||
else -> filteredMedia.filter {
|
||||
media = (when {
|
||||
getVideosOnly -> media.filter { it.type == TYPE_VIDEOS }
|
||||
getImagesOnly -> media.filter { it.type == TYPE_IMAGES }
|
||||
else -> media.filter {
|
||||
(filterMedia and TYPE_IMAGES != 0 && it.type == TYPE_IMAGES) ||
|
||||
(filterMedia and TYPE_VIDEOS != 0 && it.type == TYPE_VIDEOS) ||
|
||||
(filterMedia and TYPE_GIFS != 0 && it.type == TYPE_GIFS)
|
||||
}
|
||||
}) as ArrayList<Medium>
|
||||
|
||||
MediaFetcher(this).sortMedia(filteredMedia, config.getFileSorting(path))
|
||||
callback(filteredMedia)
|
||||
MediaFetcher(this).sortMedia(media, config.getFileSorting(path))
|
||||
callback(media)
|
||||
|
||||
media.filter { !getDoesFilePathExist(it.path) }.forEach {
|
||||
mediumDao.deleteMediumPath(it.path)
|
||||
|
|
|
@ -8,9 +8,6 @@ import com.simplemobiletools.gallery.models.Medium
|
|||
|
||||
@Dao
|
||||
interface MediumDao {
|
||||
@Query("SELECT * FROM media")
|
||||
fun getAll(): List<Medium>
|
||||
|
||||
@Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type FROM media WHERE parent_path = :path")
|
||||
fun getMediaFromPath(path: String): List<Medium>
|
||||
|
||||
|
|
Loading…
Reference in a new issue