adding some crashfixes

This commit is contained in:
tibbi 2021-02-12 22:18:14 +01:00
parent 3f50700b85
commit 01da232d39
2 changed files with 10 additions and 9 deletions

View File

@ -393,7 +393,9 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
val sourceFolder = sourceFile.toFileDirItem(activity) val sourceFolder = sourceFile.toFileDirItem(activity)
activity.deleteFile(sourceFolder, true) { activity.deleteFile(sourceFolder, true) {
listener?.refreshItems() listener?.refreshItems()
finishActMode() activity.runOnUiThread {
finishActMode()
}
} }
} }
} }

View File

@ -230,20 +230,19 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
private fun getRegularItemsOf(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) { private fun getRegularItemsOf(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) {
val items = ArrayList<ListItem>() val items = ArrayList<ListItem>()
val files = File(path).listFiles()?.filterNotNull() val files = File(path).listFiles()?.filterNotNull()
if (context == null) { if (context == null || files == null) {
callback(path, items) callback(path, items)
return return
} }
val lastModifieds = context!!.getFolderLastModifieds(path)
val isSortingBySize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0 val isSortingBySize = context!!.config.getFolderSorting(currentPath) and SORT_BY_SIZE != 0
val getProperChildCount = context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_LIST val getProperChildCount = context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_LIST
if (files != null) { val lastModifieds = context!!.getFolderLastModifieds(path)
for (file in files) {
val fileDirItem = getFileDirItemFromFile(file, isSortingBySize, lastModifieds, getProperChildCount) for (file in files) {
if (fileDirItem != null) { val fileDirItem = getFileDirItemFromFile(file, isSortingBySize, lastModifieds, getProperChildCount)
items.add(fileDirItem) if (fileDirItem != null) {
} items.add(fileDirItem)
} }
} }