Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paging library - Can't stop loading items

I'm using Paging library to load date directly from network. Do I have to implement logic to stop fetching data? In my case, that can be when received item count is lower than page size. Currently when I reach end of list lib keeps loading new pages.

like image 326
Rade Avatar asked Jul 20 '18 17:07

Rade


1 Answers

Theoretically, PageKeyedDataSource has a result callback,

PageKeyedDataSource.LoadCallback

And that has an onResult method, where the docs says

Pass an empty list if there is no more data to load.

Pass the key for the subsequent page to load to adjacentPageKey. For example, if you've loaded a page in loadBefore(LoadParams, LoadCallback), pass the key for the previous page, or null if the loaded page is the first. If in loadAfter(LoadParams, LoadCallback), pass the key for the next page, or null if the loaded page is the last.

So it says you should pass an empty list, and null for adjacent page key, and it should work.

like image 54
EpicPandaForce Avatar answered Sep 23 '22 22:09

EpicPandaForce