before Compose I use to hide keyboard when user started scrolling so that they can see more rows of the recyclerView this was the code I was using.
Copy code
recyclerView!!.setOnTouchListener { v, event ->
val imm = requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(v.windowToken, 0)
false
}
was it the preferred way to to this now with compose?
I have already considered using isScrollInProgress of LazyListState but I think this may not be suitable for this use-case.
a
Albert Chang
09/13/2021, 3:30 PM
Why do you think so?
a
Ali Zargar Shabestari
09/13/2021, 11:12 PM
if I put that inside a if clause it will get called with every recomposition
a
Albert Chang
09/13/2021, 11:56 PM
That's why you should use effects:
Copy code
val keyboardController = LocalSoftwareKeyboardController.current
LaunchedEffect(listState.isScrollInProgress) {
if (listState.isScrollInProgress) keyboardController?.hide()
}