before Compose I use to hide keyboard when user st...
# compose
a
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
Why do you think so?
a
if I put that inside a if clause it will get called with every recomposition
a
That's why you should use effects:
Copy code
val keyboardController = LocalSoftwareKeyboardController.current
LaunchedEffect(listState.isScrollInProgress) {
    if (listState.isScrollInProgress) keyboardController?.hide()
}
a
That worked! Thanks
👍 1