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) {
|
||||
val items = ArrayList<FileDirItem>()
|
||||
val base = File(path)
|
||||
val files = base.listFiles()
|
||||
val files = File(path).listFiles()?.filterNotNull()
|
||||
if (files == null) {
|
||||
callback(items)
|
||||
return
|
||||
|
|
|
@ -75,17 +75,24 @@ private fun getDirectoryFileCount(dir: File, countHiddenItems: Boolean): Int {
|
|||
return count
|
||||
}
|
||||
|
||||
fun File.getDirectChildrenCount(context: Context, countHiddenItems: Boolean) =
|
||||
if (context.isRestrictedSAFOnlyRoot(path)) context.getAndroidSAFDirectChildrenCount(
|
||||
fun File.getDirectChildrenCount(context: Context, countHiddenItems: Boolean): Int {
|
||||
val fileCount = if (context.isRestrictedSAFOnlyRoot(path)) {
|
||||
context.getAndroidSAFDirectChildrenCount(
|
||||
path,
|
||||
countHiddenItems
|
||||
) else listFiles()?.filter {
|
||||
)
|
||||
} else {
|
||||
listFiles()?.filter {
|
||||
if (countHiddenItems) {
|
||||
true
|
||||
} else {
|
||||
!it.name.startsWith('.')
|
||||
}
|
||||
}?.size ?: 0
|
||||
}
|
||||
|
||||
return fileCount
|
||||
}
|
||||
|
||||
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
|
||||
while (true) {
|
||||
val noMediaPath = "${curFile.absolutePath}/$NOMEDIA"
|
||||
|
|
Loading…
Reference in a new issue