minor code style update for better readability
This commit is contained in:
parent
28f1556e3e
commit
7f60661dd6
2 changed files with 23 additions and 14 deletions
|
@ -244,8 +244,7 @@ class FilePickerDialog(
|
||||||
|
|
||||||
private fun getRegularItems(path: String, lastModifieds: HashMap<String, Long>, callback: (List<FileDirItem>) -> Unit) {
|
private fun getRegularItems(path: String, lastModifieds: HashMap<String, Long>, callback: (List<FileDirItem>) -> Unit) {
|
||||||
val items = ArrayList<FileDirItem>()
|
val items = ArrayList<FileDirItem>()
|
||||||
val base = File(path)
|
val files = File(path).listFiles()?.filterNotNull()
|
||||||
val files = base.listFiles()
|
|
||||||
if (files == null) {
|
if (files == null) {
|
||||||
callback(items)
|
callback(items)
|
||||||
return
|
return
|
||||||
|
|
|
@ -75,17 +75,24 @@ private fun getDirectoryFileCount(dir: File, countHiddenItems: Boolean): Int {
|
||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
|
||||||
fun File.getDirectChildrenCount(context: Context, countHiddenItems: Boolean) =
|
fun File.getDirectChildrenCount(context: Context, countHiddenItems: Boolean): Int {
|
||||||
if (context.isRestrictedSAFOnlyRoot(path)) context.getAndroidSAFDirectChildrenCount(
|
val fileCount = if (context.isRestrictedSAFOnlyRoot(path)) {
|
||||||
|
context.getAndroidSAFDirectChildrenCount(
|
||||||
path,
|
path,
|
||||||
countHiddenItems
|
countHiddenItems
|
||||||
) else listFiles()?.filter {
|
)
|
||||||
|
} else {
|
||||||
|
listFiles()?.filter {
|
||||||
if (countHiddenItems) {
|
if (countHiddenItems) {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
!it.name.startsWith('.')
|
!it.name.startsWith('.')
|
||||||
}
|
}
|
||||||
}?.size ?: 0
|
}?.size ?: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileCount
|
||||||
|
}
|
||||||
|
|
||||||
fun File.toFileDirItem(context: Context) = FileDirItem(absolutePath, name, context.getIsPathDirectory(absolutePath), 0, length(), lastModified())
|
fun File.toFileDirItem(context: Context) = FileDirItem(absolutePath, name, context.getIsPathDirectory(absolutePath), 0, length(), lastModified())
|
||||||
|
|
||||||
|
@ -97,7 +104,10 @@ fun File.containsNoMedia(): Boolean {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun File.doesThisOrParentHaveNoMedia(folderNoMediaStatuses: HashMap<String, Boolean>, callback: ((path: String, hasNoMedia: Boolean) -> Unit)?): Boolean {
|
fun File.doesThisOrParentHaveNoMedia(
|
||||||
|
folderNoMediaStatuses: HashMap<String, Boolean>,
|
||||||
|
callback: ((path: String, hasNoMedia: Boolean) -> Unit)?
|
||||||
|
): Boolean {
|
||||||
var curFile = this
|
var curFile = this
|
||||||
while (true) {
|
while (true) {
|
||||||
val noMediaPath = "${curFile.absolutePath}/$NOMEDIA"
|
val noMediaPath = "${curFile.absolutePath}/$NOMEDIA"
|
||||||
|
|
Loading…
Reference in a new issue