I have a recycler view and I want to navigate to i...
# android
b
I have a recycler view and I want to navigate to item details on click how do I do it? I mean this works just fine (from inside of adapter)
Copy code
holder.rootView.setOnClickListener {
            it.findNavController().navigate(R.id.numberDetailsScreen, bundleOf("numberName" to item.name))
        }
the thing is that (from what I know) convention tells you to create Navigator interface but doing so would require passing the event up somehow so I could call this
Copy code
interface NumbersListNavigator {
    fun openNumberDetailsActivity(numberName: String)
}
l
dont you think you should use a callback from the adapter to fragment, and then the fragment handle this navigation?w
👍 1
b
yeah, I've closed the slack and did exactly what you're saying 😄
Copy code
class NumbersListAdapter(
    val onItemClickCallback: KFunction1<@ParameterName(name = "numberName") String, Unit>
)
l
nice
b
@Raul Tunduc that's even better
thanks both of you ❤️
r