Android Firebase pagination with recyclerview

I have a long data set in a Firebase database, and I want to create pagination functionality for an application.

I read other answers and they suggest using this method

DatabaseReference jokesRef = FirebaseDatabase.getInstance().getReference().child("child");
Query jokesQuery = jokesRef.orderByKey().startAt(offset).limitToLast(count).addValueEventListener(new OnValueEventListener() {
    ...
};
offset += count

But that would mean adding multi-valued ValueEventListeners, one for each page.

Also, what if pages load immediately? as the user scrolls the page to the 10th page, this means that all 10 pages remain in memory, and when the device changes orientation or any other configuration, all pages will be lost and reloaded.

+4
source share

Source: https://habr.com/ru/post/1682833/


All Articles