I have several fragments hosted in one activity. When some fragments are closed it is necessary to hide keyboard if opened, what is usually done via chaining onOptionsItemSelected from activity to fragment
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
android.R.id.home -> {
UiUtil.hideKeyboard(activity)
return true
}
else -> return super.onOptionsItemSelected(item)
}
}
But it looks really bad when Navigation Architecture Component is used. Is there any simple way to hide keyboard with Navigation Architecture Component ?