From 521465929536b3e149d058eadc94fa3d94ca6518 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 7 Jan 2018 21:14:04 +0100 Subject: [PATCH] make sure the activity is alive at getting the items --- .../filemanager/fragments/ItemsFragment.kt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt index 43985fa8..797a5043 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt @@ -169,14 +169,12 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum private fun getItems(path: String, callback: (items: ArrayList) -> Unit) { Thread { - if (activity?.isActivityDestroyed() == true) { - return@Thread - } - - if (!context!!.config.enableRootAccess || !context!!.isPathOnRoot(path)) { - getRegularItemsOf(path, callback) - } else { - RootHelpers().getFiles(activity as SimpleActivity, path, callback) + if (activity?.isActivityDestroyed() == false) { + if (!context!!.config.enableRootAccess || !context!!.isPathOnRoot(path)) { + getRegularItemsOf(path, callback) + } else { + RootHelpers().getFiles(activity as SimpleActivity, path, callback) + } } }.start() } @@ -192,7 +190,7 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum continue val children = getChildrenCount(file) - val size = if (file.isDirectory && context!!.config.sorting == SORT_BY_SIZE) getDirectorySize(file) else file.length() + val size = if (file.isDirectory && context?.config?.sorting == SORT_BY_SIZE) getDirectorySize(file) else file.length() val fileDirItem = FileDirItem(curPath, curName, file.isDirectory, children, size) items.add(fileDirItem) }