How to implement infinite scroll with RecyclerView in Android using Parse

779 Views Asked by At

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?

1

There are 1 best solutions below

0
On

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; 
            }

        });