Two livedata for Artist detail and releases
As there are many queries to make to fill an artist info, I propose an architecture something like this:
- When Activity receives the
MBID
in the Intent, asks the ViewModel to start fetching the artist data. - ViewModel then will get the artist from the repository. Once it has the artist with its releases:
- Updates the
artist
LiveData, which will be observed by the Details Fragment to show name/birth_data/etc. -
Transforms the stream by getting the releases and for each one queries the Repository to get the cover art URLs for each release. Then updates a different
releases
LiveData (that includes release info and cover URLs) that will be observed by Releases Fragment to render a list.
- Updates the
Other alternative:
Instead of querying all the releases for the URL, another alternative is returning releases like List<Pair<Release,Url>>
. And do something like if viewholder asks the viewModel to update release X with its cover art –> viewModel re-emits the same release list (but that release item will have URL info) –> notifies the recyclerview -> viewholder now binds an item that has URL inside on it.