Append from multiple sources to adapter list on scrolling down

235 Views Asked by At

I have a RecyclerView and it uses a data source to load the items in the adapter in parts as the user scrolls down i.e. kind of "pagination".
I need to add items in the list from different data sources and I really can't modify the first data source I mentioned to serve everything.
The problem is: as I scroll down how do I know which data source to use and add items from there? E.g.
1. Add items from Source-A
2. User scrolls
3. Add items from Source-B
4. User scrolls
5. There are no more items from Source-A and the header for items from Source-B is visible so I should start loading from Source-B etc
Is there a clean way to implement this? I don't want to start doing checks how many data were loaded from Source-A etc. I mean is there a pattern to do this based on visibility e.g. of the header?

1

There are 1 best solutions below

3
On

You can't typically feed a recyclerview adapter more than one list. You can build a list out of multiple data sources and if need be have the adapter package each type of data separately.