3

I am currently using MVP pattern to develop an android application. I have to implement pagination (i.e. on scrolling at the bottom of the RecyclerView I need to fetch new data). So what is the best way to handle current page state in this scenario?

2
+50

I'm not sure if this is a complete answer, but at least it's a start: for the pagination with the RecycleView you need to listen on the onScroll event please refer to this for more info: https://stackoverflow.com/a/26643292/1453710 and this: https://medium.com/@etiennelawlor/pagination-with-recyclerview-1cb7e66a502b#.t32xnxkw8

for the state part i would start with this: https://stackoverflow.com/a/27954678/1453710

obviously that is not a complete solution you will need to keep both the page index and the index of the first visible item on that page when saving that sate. the easiest thing i would do (assuming you have a small set of data) is save the first 3 digits for the page and the last 2 for the index of the first visible item so page 3 item 4 would be 00304

Hope this helps.

1

For pagination, there are JQuery plugins that will be quite helpful. Please give a try. Also, as far as I know RecycleView is used for defining views in Android and this class implements some view interfaces so you can try for some predefined classes or interfaces that can be easily extended or implemented with RecycleView.

You can check this link RecycleView if you could able to find something.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.