mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
make sure folder inclusion is recursive on OTG too
This commit is contained in:
parent
c0f600c451
commit
a24050c98d
3 changed files with 20 additions and 7 deletions
|
@ -760,7 +760,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
if (!getDoesFilePathExist(it.path)) {
|
||||
invalidDirs.add(it)
|
||||
} else {
|
||||
val children = if (it.path.startsWith(OTG_PATH)) getOTGFolderChildren(it.path) else File(it.path).list()?.asList()
|
||||
val children = if (it.path.startsWith(OTG_PATH)) getOTGFolderChildrenNames(it.path) else File(it.path).list()?.asList()
|
||||
val hasMediaFile = children?.any { it.isImageVideoGif() } ?: false
|
||||
if (!hasMediaFile) {
|
||||
invalidDirs.add(it)
|
||||
|
@ -777,8 +777,6 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
}
|
||||
}
|
||||
|
||||
private fun getOTGFolderChildren(path: String) = getDocumentFile(path)?.listFiles()?.map { it.name }?.toList()
|
||||
|
||||
private fun getCurrentlyDisplayedDirs() = getRecyclerAdapter()?.dirs ?: ArrayList()
|
||||
|
||||
private fun getBubbleTextItem(index: Int) = getRecyclerAdapter()?.dirs?.getOrNull(index)?.getBubbleText() ?: ""
|
||||
|
|
|
@ -326,3 +326,7 @@ fun Context.updateDBMediaPath(oldPath: String, newPath: String) {
|
|||
fun Context.updateDBDirectory(directory: Directory) {
|
||||
galleryDB.DirectoryDao().updateDirectory(directory.path, directory.tmb, directory.mediaCnt, directory.modified, directory.taken, directory.size, directory.types)
|
||||
}
|
||||
|
||||
fun Context.getOTGFolderChildren(path: String) = getDocumentFile(path)?.listFiles()
|
||||
|
||||
fun Context.getOTGFolderChildrenNames(path: String) = getOTGFolderChildren(path)?.map { it.name }?.toList()
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.simplemobiletools.commons.helpers.OTG_PATH
|
|||
import com.simplemobiletools.commons.helpers.photoExtensions
|
||||
import com.simplemobiletools.commons.helpers.videoExtensions
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.extensions.getOTGFolderChildren
|
||||
import com.simplemobiletools.gallery.extensions.shouldFolderBeVisible
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
import java.io.File
|
||||
|
@ -143,10 +144,20 @@ class MediaFetcher(val context: Context) {
|
|||
|
||||
private fun addFolder(curFolders: ArrayList<String>, folder: String) {
|
||||
curFolders.add(folder)
|
||||
val files = File(folder).listFiles() ?: return
|
||||
for (file in files) {
|
||||
if (file.isDirectory) {
|
||||
addFolder(curFolders, file.absolutePath)
|
||||
if (folder.startsWith(OTG_PATH)) {
|
||||
val files = context.getOTGFolderChildren(folder) ?: return
|
||||
for (file in files) {
|
||||
if (file.isDirectory) {
|
||||
val relativePath = file.uri.path.substringAfterLast("${context.config.OTGPartition}:")
|
||||
addFolder(curFolders, "$OTG_PATH$relativePath")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val files = File(folder).listFiles() ?: return
|
||||
for (file in files) {
|
||||
if (file.isDirectory) {
|
||||
addFolder(curFolders, file.absolutePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue