I have a fragment and a recyclerview adapter with ...
# android
I have a fragment and a recyclerview adapter with a couple holders and all need to know whether my app is currently in RO or RW mode to render the UI correctly (inputs vs just text, buttons GONE vs VISIBLE, etc.) RIght now I’m passing a LiveData from the viewmodel to the fragment to the adapter to the holders. THis is a lot of tight coupling. Is there a better way? This is pretty much the only bit of data that seems like it’s more “global” than anything else, which I’ve got pretty compartmentalized into whatever object actually needs that data.
You could define a ViewModel (the concept, not the type) for the list item, and have only the Fragment observe the LiveData, and then notify the adapter with an updated ViewModel. I don’t see any problems with everyone working with an observable data source though, especially if we’re talking about such internal changes as the button inside the list item changing visibility