From 226040e26b2f1e56ddfe1bab760a51fd3af2651d Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 13 Oct 2021 16:50:09 +0200 Subject: [PATCH] refresh mime types list on some menu actions --- .../pro/activities/MimeTypesActivity.kt | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MimeTypesActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MimeTypesActivity.kt index e6ae160b..9154eb3d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MimeTypesActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MimeTypesActivity.kt @@ -51,10 +51,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener { ) ensureBackgroundThread { - getProperFileDirItems { fileDirItems -> - val listItems = getListItemsFromFileDirItems(fileDirItems) - setupAdapter(listItems) - } + reFetchItems() } } @@ -104,7 +101,9 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener { return true } - override fun refreshFragment() {} + override fun refreshFragment() { + recreateList() + } override fun deleteFiles(files: ArrayList) {} @@ -118,9 +117,11 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener { override fun toggleFilenameVisibility() { config.displayFilenames = !config.displayFilenames + getRecyclerAdapter()?.updateDisplayFilenamesInGrid() } - override fun increaseColumnCount() {} + override fun increaseColumnCount() { + } override fun reduceColumnCount() {} @@ -257,15 +258,28 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener { private fun showSortingDialog() { ChangeSortingDialog(this, currentMimeType) { - val listItems = getRecyclerAdapter()?.listItems - if (listItems != null) { - setupAdapter(listItems as ArrayList) - } + recreateList() } } private fun changeViewType() { - ChangeViewTypeDialog(this, currentMimeType, true) { } + ChangeViewTypeDialog(this, currentMimeType, true) { + recreateList() + } + } + + private fun reFetchItems() { + getProperFileDirItems { fileDirItems -> + val listItems = getListItemsFromFileDirItems(fileDirItems) + setupAdapter(listItems) + } + } + + private fun recreateList() { + val listItems = getRecyclerAdapter()?.listItems + if (listItems != null) { + setupAdapter(listItems as ArrayList) + } } private fun tryToggleTemporarilyShowHidden() { @@ -280,5 +294,6 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener { private fun toggleTemporarilyShowHidden(show: Boolean) { config.temporarilyShowHidden = show + reFetchItems() } }