mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
Merge pull request #1218 from Nephys222/BackPress
fix for searchview anormal behavior
This commit is contained in:
commit
a4b722138e
@ -162,8 +162,6 @@ class MainActivity : BaseActivity() {
|
|||||||
// new way of handling back presses
|
// new way of handling back presses
|
||||||
onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
|
onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
// remove focus from search
|
|
||||||
removeSearchFocus()
|
|
||||||
navController.popBackStack(R.id.searchFragment, false)
|
navController.popBackStack(R.id.searchFragment, false)
|
||||||
|
|
||||||
if (binding.mainMotionLayout.progress == 0F) {
|
if (binding.mainMotionLayout.progress == 0F) {
|
||||||
@ -260,6 +258,7 @@ class MainActivity : BaseActivity() {
|
|||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
bundle.putString("query", query)
|
bundle.putString("query", query)
|
||||||
navController.navigate(R.id.searchResultFragment, bundle)
|
navController.navigate(R.id.searchResultFragment, bundle)
|
||||||
|
searchViewModel.setQuery("")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,24 +283,12 @@ class MainActivity : BaseActivity() {
|
|||||||
override fun onMenuItemActionCollapse(p0: MenuItem): Boolean {
|
override fun onMenuItemActionCollapse(p0: MenuItem): Boolean {
|
||||||
val currentFragmentId = navController.currentDestination?.id
|
val currentFragmentId = navController.currentDestination?.id
|
||||||
if (currentFragmentId == R.id.searchFragment || currentFragmentId == R.id.searchResultFragment) {
|
if (currentFragmentId == R.id.searchFragment || currentFragmentId == R.id.searchResultFragment) {
|
||||||
try {
|
navController.popBackStack()
|
||||||
onBackPressedDispatcher.onBackPressed()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
searchView.setOnCloseListener {
|
|
||||||
if (navController.currentDestination?.id == R.id.searchFragment) {
|
|
||||||
searchViewModel.setQuery(null)
|
|
||||||
onBackPressedDispatcher.onBackPressed()
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
return super.onCreateOptionsMenu(menu)
|
return super.onCreateOptionsMenu(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user