Skip to content

Commit

Permalink
Merge pull request #78 from MichaelMcDonnell/fix-scroll-perf
Browse files Browse the repository at this point in the history
Fix scroll down performance
  • Loading branch information
naveensingh authored Dec 29, 2024
2 parents 3385c28 + 76a2509 commit f29d203
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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()
}
}
Expand Down

0 comments on commit f29d203

Please sign in to comment.