I am building a very simple Shopping List app using Room and MVVM.
Objective: Animate the quantity textView in recycler according to the action, if increased the slide down, if decreased the slide up.
Problem: Do not know to handle the click event of a button in the recycler view item. Right now the button is calling the interface's method which is being handled by Activity, which calls the ViewModels function which increases the values in the Database. On the bases of that, the recycler view gets updated because it is listing to the changes.
Possible Solution I can think of: Add a Channel of events in ViewModel, and when the add or remove method is called, fire a related event. Observers these events in MainActivity, and then from there call the appropriate adapter function which properly handles the addition or subtraction of quantity items. But don't you think this will generate a ton of boilerplate code?
It's more of an architectural problem than a coding problem.
Please help me out with this. Here is the code of my app: https://github.com/waqas-334/MVVM-TODO-Android-app/tree/bugs
Thank you in advance.