Skip to content
This repository has been archived by the owner on Aug 3, 2019. It is now read-only.

Pagination

Roman Kushnarenko edited this page Oct 16, 2014 · 1 revision

When you ask for photos, albums and other list of entities, you will get the first page of results. Usualy it is 25 first results. For getting next or previous pages you can use methods below or get Cursor and start iterating.

Each OnActionListener has next methods:

  • hasNext() - return true if one more page exists
  • hasPrev() - return true if previous page exists
  • getNext() - execute request for getting next page and the results return to the same listener
  • getPrev() - execute request for getting previous page and the results return to the same listener
  • getCursor() - return Cursor which has the same methods above

Example:

Let's say we are asking for comments by: getCommets(entityId, onCommentsListener).
We want to check if there is more pages with comments. If so, we will ask for more.

And this is our listener:

OnCommentsListener onCommentsListener = new OnCommentsListener() {			
	@Override
	public void onComplete(List<Comment> comments) {
		Log.i(TAG, "Number of comments = " + comments.size());
		if (hasNext()) {
			getNext();
		}
	}
};

Of course, it is just an example. In your app, you will maybe add a button that will say 'get more...' and then you will actually call for getNext() but it is up to you how to handle it. You can getCursor() and iterate to the next pages from other place in you app. Again, it's up to you :)

Clone this wiki locally