Skip to content

Commit f8831b1

Browse files
committed
simplifying search handling
1 parent 1c913cf commit f8831b1

File tree

2 files changed

+1
-22
lines changed

2 files changed

+1
-22
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,6 @@ class MainActivity : SimpleActivity() {
199199
main_menu.toggleHideOnScroll(false)
200200
main_menu.setupMenu()
201201

202-
main_menu.onSearchOpenListener = {
203-
(getCurrentFragment() as? ItemsFragment)?.searchOpened()
204-
}
205-
206202
main_menu.onSearchClosedListener = {
207203
getAllFragments().forEach {
208204
it?.searchQueryChanged("")

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ import java.io.File
3030
class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), ItemOperationsListener,
3131
Breadcrumbs.BreadcrumbsListener {
3232
private var showHidden = false
33-
private var skipItemUpdating = false
34-
private var isSearchOpen = false
3533
private var lastSearchedText = ""
3634
private var scrollStates = HashMap<String, Parcelable>()
3735
private var zoomListener: MyRecyclerView.MyZoomListener? = null
@@ -134,7 +132,6 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
134132
}
135133

136134
private fun addItems(items: ArrayList<ListItem>, forceRefresh: Boolean = false) {
137-
skipItemUpdating = false
138135
activity?.runOnUiThread {
139136
items_swipe_refresh?.isRefreshing = false
140137
breadcrumbs.setBreadcrumb(currentPath)
@@ -173,7 +170,6 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
173170

174171
@SuppressLint("NewApi")
175172
private fun getItems(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) {
176-
skipItemUpdating = false
177173
ensureBackgroundThread {
178174
if (activity?.isDestroyed == false && activity?.isFinishing == false) {
179175
val config = context!!.config
@@ -288,7 +284,6 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
288284

289285
private fun openDirectory(path: String) {
290286
(activity as? MainActivity)?.apply {
291-
skipItemUpdating = isSearchOpen
292287
openedDirectory()
293288
}
294289
openPath(path)
@@ -394,20 +389,8 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
394389
return files
395390
}
396391

397-
fun searchOpened() {
398-
isSearchOpen = true
392+
private fun searchClosed() {
399393
lastSearchedText = ""
400-
}
401-
402-
fun searchClosed() {
403-
isSearchOpen = false
404-
if (!skipItemUpdating) {
405-
getRecyclerAdapter()?.updateItems(storedItems)
406-
}
407-
408-
skipItemUpdating = false
409-
lastSearchedText = ""
410-
411394
items_swipe_refresh.isEnabled = activity?.config?.enablePullToRefresh != false
412395
items_fastscroller.beVisible()
413396
items_placeholder.beGone()

0 commit comments

Comments
 (0)