2

Most of the articles I found online used setLimit function to load more items. But it is not an efficient way as we would be recalling the existing objects.

I'm using a RecyclerView with a custom adapter to load my list items. Once I receive the list of objects from Parse server, I group few items based on my algorithm and pass it to my Custom Adapter.

I got to know that ParseQueryAdapter is another way to implement pagination. Can someone suggest how I can use ParseQueryAdapter with my custom adapter?

Anirudh
  • 2,767
  • 5
  • 69
  • 119
  • Common rest services are able to send a list with a defined offset, so you can download the first 20 items, and then call for the next 20 without downloading the first 20 again. Anyway, your adapter should not have nothing to do with your dataSource, they should be independent. – Nanoc Nov 24 '15 at 09:17

1 Answers1

3

Finally I solved it by using setSkip function.

Code:

private int limit =0; 
private boolean loadMore = false;  



ParseQuery<ParseObject> query = ParseQuery.getQuery("ClassName");

if(loadMore==true)
    {
        query.setSkip(limit); 
        query.setLimit(12);
    } 
    else
    {
        query.setLimit(12); 
    }

query.findInBackground(new FindCallback<ParseObject>() 
     {

        @Override
        public void done(List<ParseObject> arg0, ParseException arg1) 
        { 
            limit = limit+ arg0.size(); 

            if(arg0.size()==0)
            {
                loadMore = false; 
            }
            else
            {
                loadMore = true; 
            }

        });
Anirudh
  • 2,767
  • 5
  • 69
  • 119