diff --git a/app/build.gradle b/app/build.gradle index 8381fe2a..fd8dec94 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -42,7 +42,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:3.8.3' + implementation 'com.simplemobiletools:commons:3.8.7' implementation files('../libs/RootTools.jar') diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt index ea93bc2e..8ea85d53 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt @@ -26,6 +26,7 @@ import com.simplemobiletools.filemanager.R import com.simplemobiletools.filemanager.activities.SimpleActivity import com.simplemobiletools.filemanager.dialogs.CompressAsDialog import com.simplemobiletools.filemanager.extensions.* +import com.simplemobiletools.filemanager.interfaces.ItemOperationsListener import com.stericson.RootTools.RootTools import kotlinx.android.synthetic.main.list_item.view.* import java.io.Closeable @@ -424,12 +425,4 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList) - - fun selectedPaths(paths: ArrayList) - } } 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 ea6c09b7..5f37b78f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt @@ -23,6 +23,7 @@ import com.simplemobiletools.filemanager.extensions.isPathOnRoot import com.simplemobiletools.filemanager.extensions.openFile import com.simplemobiletools.filemanager.helpers.PATH import com.simplemobiletools.filemanager.helpers.RootHelpers +import com.simplemobiletools.filemanager.interfaces.ItemOperationsListener import com.stericson.RootTools.RootTools import kotlinx.android.synthetic.main.items_fragment.* import kotlinx.android.synthetic.main.items_fragment.view.* @@ -30,11 +31,12 @@ import java.io.File import java.util.HashMap import kotlin.collections.ArrayList -class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrumbs.BreadcrumbsListener { +class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.BreadcrumbsListener { var currentPath = "" var isGetContentIntent = false var isGetRingtonePicker = false var isPickMultipleIntent = false + var isFirstResume = true private var showHidden = false private var skipItemUpdating = false @@ -90,7 +92,10 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum items_fastscroller.updateBubbleColors() items_fastscroller.allowBubbleDisplay = context!!.config.showInfoBubble - refreshItems() + if (!isFirstResume) { + refreshItems() + } + isFirstResume = false } override fun onPause() { @@ -110,15 +115,17 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum } var realPath = path.trimEnd('/') - if (realPath.isEmpty()) + if (realPath.isEmpty()) { realPath = "/" + } - scrollStates.put(currentPath, getScrollState()) + scrollStates[currentPath] = getScrollState() currentPath = realPath showHidden = context!!.config.shouldShowHidden getItems(currentPath) { - if (!isAdded) + if (!isAdded) { return@getItems + } FileDirItem.sorting = context!!.config.getFolderSorting(currentPath) it.sort() @@ -183,8 +190,9 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum for (file in files) { val curPath = file.absolutePath val curName = curPath.getFilenameFromPath() - if (!showHidden && curName.startsWith(".")) + if (!showHidden && curName.startsWith(".")) { continue + } val children = getChildrenCount(file) val size = if (file.isDirectory && context?.config?.sorting == SORT_BY_SIZE) getDirectorySize(file) else file.length() diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/interfaces/ItemOperationsListener.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/interfaces/ItemOperationsListener.kt new file mode 100644 index 00000000..40b5fbae --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/interfaces/ItemOperationsListener.kt @@ -0,0 +1,12 @@ +package com.simplemobiletools.filemanager.interfaces + +import java.io.File +import java.util.* + +interface ItemOperationsListener { + fun refreshItems() + + fun deleteFiles(files: ArrayList) + + fun selectedPaths(paths: ArrayList) +}