finish actionmode and search on swiping between tabs
This commit is contained in:
parent
8226588d95
commit
be0fba6be8
|
@ -13,6 +13,7 @@ import android.view.Menu
|
|||
import android.view.MenuItem
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.MenuItemCompat
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
|
@ -316,6 +317,25 @@ class MainActivity : SimpleActivity() {
|
|||
)
|
||||
|
||||
setupTabColors(tabToOpen)
|
||||
|
||||
main_view_pager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
if (isSearchOpen) {
|
||||
getCurrentFragment()?.searchQueryChanged("")
|
||||
searchMenuItem?.collapseActionView()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
main_tabs_holder.getTabAt(position)?.select()
|
||||
getAllFragments().forEach {
|
||||
it?.finishActMode()
|
||||
}
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun setupTabColors(lastUsedTab: Int) {
|
||||
|
|
|
@ -77,7 +77,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||
getRecyclerAdapter()?.updateDateTimeFormat()
|
||||
}
|
||||
|
||||
fun finishActMode() {
|
||||
override fun finishActMode() {
|
||||
getRecyclerAdapter()?.finishActMode()
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||
openPath(path)
|
||||
}
|
||||
|
||||
fun searchQueryChanged(text: String) {
|
||||
override fun searchQueryChanged(text: String) {
|
||||
val searchText = text.trim()
|
||||
lastSearchedText = searchText
|
||||
ensureBackgroundThread {
|
||||
|
|
|
@ -13,4 +13,8 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||
abstract fun setupFontSize()
|
||||
|
||||
abstract fun setupDateTimeFormat()
|
||||
|
||||
abstract fun searchQueryChanged(text: String)
|
||||
|
||||
abstract fun finishActMode()
|
||||
}
|
||||
|
|
|
@ -64,6 +64,8 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||
}
|
||||
}
|
||||
|
||||
private fun getRecyclerAdapter() = recents_list.adapter as? ItemsAdapter
|
||||
|
||||
override fun refreshItems() {}
|
||||
|
||||
override fun deleteFiles(files: ArrayList<FileDirItem>) {}
|
||||
|
@ -73,4 +75,10 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||
override fun setupFontSize() {}
|
||||
|
||||
override fun setupDateTimeFormat() {}
|
||||
|
||||
override fun searchQueryChanged(text: String) {}
|
||||
|
||||
override fun finishActMode() {
|
||||
getRecyclerAdapter()?.finishActMode()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue