Hey there I only want to load the first 2 items from the Firebase Realtime database to my recycler view but the problem is it returns only 2 images and I want to load the first 2 images out of ‘n’ no. of image (for ex. return the first 2 images out of ‘n’ then scrolling down return 2 new images (like that in Instagram) and not download all images offscreen and show it on scrolling). Here is the code but I get only 2 fixed items. Help!
public int getItemCount() {
int size = mClicks.size();
return (size > 2 ? 2 : size);
}
2
Answers
What you’re looking for is called pagination. This means that you need to load the data progressively in smaller chunks. This was already covered a lot of times before, and this question already has a lot of solutions for the Realtime Database:
However, if you consider at some point in time trying using Cloud Firestore, I think that this answer will help:
If you want to go further and try using Jetpack Compose, then I think that this resource will help:
You should use Integer.MAX_VALUE. Something like this.
or simply use