I'm in the process of writing abstract classes for a ListAdapter with a SelectionTracker<Long>. In my case, the SelectionTracker organizes items by selectionKeys via
interface TrackedListItem {
var selectionKey : Long?
}
Now, the items in the RecyclerView (and hence, the items stored in the ListAdapter) need to bind a "viewModel" (note this doesn't extend ViewModel, I'm just following the conventions outlined in Android Sunflower). Sticking with those same conventions, my ViewHolder should take a ViewBinding as its argument:
abstract class TrackedItemViewHolder(val binding: ViewBinding) : RecyclerView.ViewHolder(binding.root)
I know ahead of time that the binding passed to the ViewHolder has a data variable viewModel that I can bind to, and I will know that this viewModel implements TrackedListItem. How can I create a generic layout (and thus binding) that effectively just passes:
<data><variable
name="viewModel"
type="...TrackedListItem" /></data>