I am writing an android chat app and I am trying to implement endless scrolling using Firebase Database in RecyrclerView using custom FirebaceRecyclerAdapter. For first messages load I get data from Firebase Database by using query that ordering data by .orderByChild() and then .limitToFirst(specificCount) so far so good. But when user scrolled to the last visible item I have to get next portion of messages and the problem comes I did not get a straight way to get messages from Firebase Database after specificCount. I tried with that code:
int startCount = mLayoutManager.getItemCount();
FirebaseDatabase
.getInstance()
.getReference()
.child(RequestParameters.FB_CHILD_MESSAGES)
.orderByChild(RequestParameters.FB_CHILD_MESSAGES_ORDERING_TIME)
.startAt(startCount)
.endAt(startCount + CustomFirebaceRecyclerAdapter.NEXT_MESSAGE_PORTION_COUNT)
.addListenerForSingleValueEvent(...)
But after I read the documentation for .startAt() I realize how stupid is this. Anyone could help to make a query that gets items after specificCount and limit received messages to some count.