https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
s

Sergio C.

10/31/2021, 3:04 PM
Hello everyone, is there a way to make paging display always a fixed number of items? I have a Realtime database which can reach thousands of items so it's not good idea to keep loading items to memory and make the app slow. Also I need to search/filter items by phone number in the entire list from the Realtime database. Is there something like this already done? How could I do this? I'm thinking of using Room to store all the items from DB so I can search easily. Now the part of keeping a fixed number of elements in the pager I don't have an idea.
j

Javier

10/31/2021, 3:14 PM
pager is a recyclerview so even you adding 1000 items to it, it will only load the visible ones
you can just try the performance if you want adding any number of items to a recyclerview
s

Scott Kruse

10/31/2021, 3:35 PM
If itemsShown.size >= yourMax // don’t fetch more data
s

Sergio C.

10/31/2021, 6:01 PM
no, when filling the adapter with thousands of items it's very slow! locking the entire UI.
s

Scott Kruse

10/31/2021, 9:37 PM
Yeah you shouldn’t do that
s

Sergio C.

11/02/2021, 9:15 AM
The problem is, there is no API to paginate Firebase Realtime Database data and also maintain the real-time update on the items displayed.
Anyone done something like this?
s

Sergio C.

11/03/2021, 10:13 PM
Thanks. I've tried the sample but we don't get auto updates on the data anymore if we enable paging.
2 Views