I have a query that looks like this:
Query first = ref.orderBy("name", Query.Direction.ASCENDING).limit(10);
This is how I display the data to my RecyclerView.
firestoreRecyclerOptions = new FirestoreRecyclerOptions.Builder<ModelClass>().setQuery(query, ModelClass.class).build();
myFirestoreRecyclerAdapter = new MyFirestoreRecyclerAdapter(firestoreRecyclerOptions);
recyclerView.setAdapter(myFirestoreRecyclerAdapter);
I'm trying to use pagination as specified in here and I cannot solve it.
first.get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot documentSnapshots) {
DocumentSnapshot lastVisible = documentSnapshots.getDocuments().get(documentSnapshots.size() - 1);
Query second = ref.orderBy("name", Query.Direction.ASCENDING).startAfter(lastVisible).limit(10);
//Create a firestoreRecyclerOptions and setting the adapter
}
});
Is there a way to paginate queries by combining query cursors using FirestoreRecyclerAdapter? Is this even possible?
from Is there a way to paginate queries by combining query cursors using FirestoreRecyclerAdapter?
No comments:
Post a Comment