mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2024-12-23 14:41:06 +01:00
do not check immediately if .nomedia folders contain media, we will check later
This commit is contained in:
parent
2cf58c2e1e
commit
795fad2240
@ -6,7 +6,6 @@ import android.database.Cursor
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import com.simplemobiletools.commons.extensions.humanizePath
|
import com.simplemobiletools.commons.extensions.humanizePath
|
||||||
import com.simplemobiletools.commons.extensions.isImageVideoGif
|
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SettingsActivity
|
import com.simplemobiletools.gallery.activities.SettingsActivity
|
||||||
@ -52,7 +51,6 @@ fun Context.launchSettings() {
|
|||||||
fun Context.getParents(): ArrayList<String> {
|
fun Context.getParents(): ArrayList<String> {
|
||||||
val uri = MediaStore.Files.getContentUri("external")
|
val uri = MediaStore.Files.getContentUri("external")
|
||||||
val columns = arrayOf(MediaStore.Images.Media.DATA)
|
val columns = arrayOf(MediaStore.Images.Media.DATA)
|
||||||
val parents = ArrayList<String>()
|
|
||||||
val parentsSet = HashSet<String>()
|
val parentsSet = HashSet<String>()
|
||||||
|
|
||||||
var cursor: Cursor? = null
|
var cursor: Cursor? = null
|
||||||
@ -69,6 +67,7 @@ fun Context.getParents(): ArrayList<String> {
|
|||||||
cursor?.close()
|
cursor?.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val parents = ArrayList<String>()
|
||||||
parentsSet.mapTo(parents, { it })
|
parentsSet.mapTo(parents, { it })
|
||||||
|
|
||||||
if (config.showHiddenFolders) {
|
if (config.showHiddenFolders) {
|
||||||
@ -109,10 +108,7 @@ fun Context.getNoMediaFolders(): ArrayList<String> {
|
|||||||
if (cursor?.moveToFirst() == true) {
|
if (cursor?.moveToFirst() == true) {
|
||||||
do {
|
do {
|
||||||
val path = cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA)) ?: continue
|
val path = cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA)) ?: continue
|
||||||
val parent = File(path).parentFile
|
folders.add(File(path).parent)
|
||||||
if (hasImageVideoGif(parent)) {
|
|
||||||
folders.add(parent.absolutePath)
|
|
||||||
}
|
|
||||||
} while (cursor.moveToNext())
|
} while (cursor.moveToNext())
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@ -122,12 +118,4 @@ fun Context.getNoMediaFolders(): ArrayList<String> {
|
|||||||
return folders
|
return folders
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasImageVideoGif(dir: File): Boolean {
|
|
||||||
if (dir.isDirectory) {
|
|
||||||
val files = dir.listFiles() ?: return false
|
|
||||||
files.filter(File::isImageVideoGif).any { return true }
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
val Context.config: Config get() = Config.newInstance(this)
|
val Context.config: Config get() = Config.newInstance(this)
|
||||||
|
Loading…
Reference in New Issue
Block a user