mirror of
https://github.com/FossifyOrg/Launcher.git
synced 2026-06-14 19:47:25 -04:00
Fix scroll down performance
Scrolling down was slow (see issue #65) because the keyboard was being hidden every time there was a scroll down event. Hiding the keyboard is an expensive operation (found through profiling). They keyboard only needs to be hidden if the search bar is being used (in focus).
This commit is contained in:
@@ -113,7 +113,10 @@ class AllAppsFragment(
|
||||
shouldIntercept =
|
||||
distance > 0 && binding.allAppsGrid.computeVerticalScrollOffset() == 0
|
||||
if (shouldIntercept) {
|
||||
activity?.hideKeyboard()
|
||||
// Hiding is expensive, only do it if focused
|
||||
if (binding.searchBar.hasFocus()) {
|
||||
activity?.hideKeyboard()
|
||||
}
|
||||
activity?.startHandlingTouches(touchDownY)
|
||||
touchDownY = -1
|
||||
}
|
||||
@@ -221,7 +224,8 @@ class AllAppsFragment(
|
||||
binding.allAppsFastscroller.setPadding(leftListPadding, 0, rightListPadding, 0)
|
||||
binding.allAppsGrid.addOnScrollListener(object : OnScrollListener() {
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
if (dy > 0 && binding.allAppsGrid.computeVerticalScrollOffset() > 0) {
|
||||
// Hiding is expensive, only do it if focused
|
||||
if (binding.searchBar.hasFocus() && dy > 0 && binding.allAppsGrid.computeVerticalScrollOffset() > 0) {
|
||||
activity?.hideKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user