In part 6 of the FirebaseUI Firestore tutorial, we will learn how to handle click events on the single items in our RecyclerView. For this we will create an interface in our RecyclerView Adapter, that contains an onItemClick method, where we pass the position and the DocumentSnapshot of the clicked item. We will trigger this interface method when we click on the itemView in our ViewHolder class. We get the position of the clicked item with getAdapterPosition and the corresponding DocumentSnapshot with getSnapshots().getSnapshot(). To make sure that the clicked item is still valid, we check if the position is not equal to RecyclerView.NO_POSITION or -1.
We can then implement this interface into our MainActivity or pass an anonymous inner class and handle the onItemClick event there.
From the DocumentSnapshot we can then deserialize our Note Java object by calling toObject, we can get the unique Firestore ID with getId, we can get the DocumentReference with getReference or getPath and more.
Watch the Cloud Firestore tutorial first: