Simple Demo To Count Items Checked in a RecyclerView
The idea is to demonstrate one relatively simple way to pass "click" events to higher levels and how to perform long-running operations on view holders (e.g. to show a progress bar while you wait for some operation to complete).
After years of StackOverflow, I realized that most people (myself included!) tend to put their logic in the wrong places. When dealing with a Recyclerview, there's a lot going on (as better as it is compared to the old ListView, it's still very boilerplatty).
The architecture is simple: Let the Adapter in peace; let the viewHolders alone, these two objects have a lot to deal with already, don't make them think.
Activity -> Adapter -> View Holder
Let the Activity (through a ViewModel) deal with whatever you want to happen. Have the Lower level components (viewholders, adapters) simply inform what happened, not make decisions on behalf of anybody.
This project simply shows a list of "Things" and a checkbox for each. There's a counter at the top that ... err... counts the number of checked items at any given time.
This is how it looks: