flip some checks at Portrait photos to make it quicker

This commit is contained in:
tibbi 2020-04-24 17:48:26 +02:00
parent aa4af8a292
commit 1b1fac9b56
3 changed files with 5 additions and 4 deletions

View file

@ -954,6 +954,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
if (!directory.isRecycleBin()) { if (!directory.isRecycleBin()) {
mediaDB.insertAll(curMedia) mediaDB.insertAll(curMedia)
} }
getCachedMedia(directory.path, getVideosOnly, getImagesOnly) { getCachedMedia(directory.path, getVideosOnly, getImagesOnly) {
it.forEach { it.forEach {
if (!curMedia.contains(it)) { if (!curMedia.contains(it)) {
@ -1163,7 +1164,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
} else if (it.path != config.tempFolderPath) { } else if (it.path != config.tempFolderPath) {
val children = if (isPathOnOTG(it.path)) getOTGFolderChildrenNames(it.path) else File(it.path).list()?.asList() val children = if (isPathOnOTG(it.path)) getOTGFolderChildrenNames(it.path) else File(it.path).list()?.asList()
val hasMediaFile = children?.any { val hasMediaFile = children?.any {
it != null && (it.isMediaFile() || (File(it).isDirectory && it.startsWith("img_", true))) it != null && (it.isMediaFile() || (it.startsWith("img_", true) && File(it).isDirectory))
} ?: false } ?: false
if (!hasMediaFile) { if (!hasMediaFile) {

View file

@ -564,7 +564,7 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag
val foldersToAdd = ArrayList<String>() val foldersToAdd = ArrayList<String>()
for (folder in foldersToScan) { for (folder in foldersToScan) {
val allFiles = File(folder).listFiles() ?: continue val allFiles = File(folder).listFiles() ?: continue
allFiles.filter { it.isDirectory && it.name.startsWith("img_", true) }.forEach { allFiles.filter { it.name.startsWith("img_", true) && it.isDirectory }.forEach {
foldersToAdd.add(it.absolutePath) foldersToAdd.add(it.absolutePath)
} }
} }

View file

@ -172,7 +172,7 @@ class MediaFetcher(val context: Context) {
val config = context.config val config = context.config
val includedFolders = config.includedFolders val includedFolders = config.includedFolders
val OTGPath = config.OTGPath val OTGPath = config.OTGPath
var foldersToScan = config.everShownFolders.filter { it == FAVORITES || it == RECYCLE_BIN || context.getDoesFilePathExist(it, OTGPath) }.toHashSet() val foldersToScan = config.everShownFolders.filter { it == FAVORITES || it == RECYCLE_BIN || context.getDoesFilePathExist(it, OTGPath) }.toHashSet()
cursor.use { cursor.use {
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
@ -244,7 +244,7 @@ class MediaFetcher(val context: Context) {
val isSvg = if (isImage || isVideo || isGif || isRaw) false else path.isSvg() val isSvg = if (isImage || isVideo || isGif || isRaw) false else path.isSvg()
if (!isImage && !isVideo && !isGif && !isRaw && !isSvg) { if (!isImage && !isVideo && !isGif && !isRaw && !isSvg) {
if (showPortraits && file.isDirectory && file.name.startsWith("img_", true)) { if (showPortraits && file.name.startsWith("img_", true) && file.isDirectory) {
val portraitFiles = file.listFiles() ?: continue val portraitFiles = file.listFiles() ?: continue
val cover = portraitFiles.firstOrNull { it.name.contains("cover", true) } ?: portraitFiles.firstOrNull() val cover = portraitFiles.firstOrNull { it.name.contains("cover", true) } ?: portraitFiles.firstOrNull()
if (cover != null && !files.contains(cover)) { if (cover != null && !files.contains(cover)) {