I am using a RecyclerView and fetching objects from an API in batches of ten. For pagination, I use EndlessRecyclerOnScrollListener.
It\'s all working properly. Now
There is another way to do this.
First your adapter's getItemCount returns listItems.size() + 1
return VIEW_TYPE_LOADING
in getItemViewType()
for position >= listItems.size()
. This way the loader will only be shown at the end of the recycler view list. The only problem with this solution is even after reaching the last page, the loader will be shown, so in order to fix that you store the x-pagination-total-count
in the adapter, and
then you change the condition to return view type to
(position >= listItem.size())&&(listItem.size <= xPaginationTotalCount)
.
I just came up with this idea now what do you think?