mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-04-11 17:01:27 +02:00
simplifying search handling
This commit is contained in:
parent
1c913cf1de
commit
f8831b150a
@ -199,10 +199,6 @@ class MainActivity : SimpleActivity() {
|
|||||||
main_menu.toggleHideOnScroll(false)
|
main_menu.toggleHideOnScroll(false)
|
||||||
main_menu.setupMenu()
|
main_menu.setupMenu()
|
||||||
|
|
||||||
main_menu.onSearchOpenListener = {
|
|
||||||
(getCurrentFragment() as? ItemsFragment)?.searchOpened()
|
|
||||||
}
|
|
||||||
|
|
||||||
main_menu.onSearchClosedListener = {
|
main_menu.onSearchClosedListener = {
|
||||||
getAllFragments().forEach {
|
getAllFragments().forEach {
|
||||||
it?.searchQueryChanged("")
|
it?.searchQueryChanged("")
|
||||||
|
@ -30,8 +30,6 @@ import java.io.File
|
|||||||
class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), ItemOperationsListener,
|
class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), ItemOperationsListener,
|
||||||
Breadcrumbs.BreadcrumbsListener {
|
Breadcrumbs.BreadcrumbsListener {
|
||||||
private var showHidden = false
|
private var showHidden = false
|
||||||
private var skipItemUpdating = false
|
|
||||||
private var isSearchOpen = false
|
|
||||||
private var lastSearchedText = ""
|
private var lastSearchedText = ""
|
||||||
private var scrollStates = HashMap<String, Parcelable>()
|
private var scrollStates = HashMap<String, Parcelable>()
|
||||||
private var zoomListener: MyRecyclerView.MyZoomListener? = null
|
private var zoomListener: MyRecyclerView.MyZoomListener? = null
|
||||||
@ -134,7 +132,6 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addItems(items: ArrayList<ListItem>, forceRefresh: Boolean = false) {
|
private fun addItems(items: ArrayList<ListItem>, forceRefresh: Boolean = false) {
|
||||||
skipItemUpdating = false
|
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
items_swipe_refresh?.isRefreshing = false
|
items_swipe_refresh?.isRefreshing = false
|
||||||
breadcrumbs.setBreadcrumb(currentPath)
|
breadcrumbs.setBreadcrumb(currentPath)
|
||||||
@ -173,7 +170,6 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private fun getItems(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) {
|
private fun getItems(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) {
|
||||||
skipItemUpdating = false
|
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
if (activity?.isDestroyed == false && activity?.isFinishing == false) {
|
if (activity?.isDestroyed == false && activity?.isFinishing == false) {
|
||||||
val config = context!!.config
|
val config = context!!.config
|
||||||
@ -288,7 +284,6 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
|
|
||||||
private fun openDirectory(path: String) {
|
private fun openDirectory(path: String) {
|
||||||
(activity as? MainActivity)?.apply {
|
(activity as? MainActivity)?.apply {
|
||||||
skipItemUpdating = isSearchOpen
|
|
||||||
openedDirectory()
|
openedDirectory()
|
||||||
}
|
}
|
||||||
openPath(path)
|
openPath(path)
|
||||||
@ -394,20 +389,8 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
return files
|
return files
|
||||||
}
|
}
|
||||||
|
|
||||||
fun searchOpened() {
|
private fun searchClosed() {
|
||||||
isSearchOpen = true
|
|
||||||
lastSearchedText = ""
|
lastSearchedText = ""
|
||||||
}
|
|
||||||
|
|
||||||
fun searchClosed() {
|
|
||||||
isSearchOpen = false
|
|
||||||
if (!skipItemUpdating) {
|
|
||||||
getRecyclerAdapter()?.updateItems(storedItems)
|
|
||||||
}
|
|
||||||
|
|
||||||
skipItemUpdating = false
|
|
||||||
lastSearchedText = ""
|
|
||||||
|
|
||||||
items_swipe_refresh.isEnabled = activity?.config?.enablePullToRefresh != false
|
items_swipe_refresh.isEnabled = activity?.config?.enablePullToRefresh != false
|
||||||
items_fastscroller.beVisible()
|
items_fastscroller.beVisible()
|
||||||
items_placeholder.beGone()
|
items_placeholder.beGone()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user