I have a RecyclerView with multiple item view types so they are broken into separate ViewHolder classes. Before, when all the ViewHolders were in the same class as the RecyclerView Adapter, I could update the adapter directly when an item was clicked or deleted. However, I separated the ViewHolders into different classes to better organize the code. Now, I cannot directly update my RecyclerView Adapter. Which of the following solutions is the best way to communicate from my ViewHolder to my Adapter? If there is a better solution than the ones I have listed, please suggest!
- Using a Interface with a Callback listener. Keep in mind that there might be 5 - 10 different view types so would this method require 5 - 10 interfaces?
- Use an Eventbus library such as Greenrobot's Eventbus.
Is an interface or eventbus solution really the best way? There surely has to be a better method for communication between views and adapters!