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?
-
3As I explain [here](http://programmers.stackexchange.com/a/321923/131624) telling us you're using MVC actually tells us very little. You also mentioned RecyclerView in android.You don't mention any particular concerns or unusual requirements so I don't see why a canned answer like this wouldn't suffice: https://developer.android.com/training/material/lists-cards.html If you have other concerns let me know. – candied_orange Jul 03 '16 at 05:22
-
Here is a quick demo of MVP design pattern in android https://androidwave.com/android-mvp-architecture-for-beginners-demo-app/ – Surya Prakash Kushawah Feb 26 '19 at 06:48
2 Answers
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.
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.

- 154
- 1
- 10