How to use recycler view

I’ve used the recycler view but nothing inside is showing up.

From my understanding, the recycler view would get more data (I’m using firestore) after reaching end of scroll?? I’m just trying to get over Firestore’s limit of 20 documents for a database that would have as many as a user would input.

Alternatively, I’m looking at some sort of pagination method or load more button but I’m having trouble putting in an index to get collection (e.g. get documents 0-20, 20-40 etc.)- where would I put it when I use the get collection method?

I’ve looked through these:

Right now I’m looking into this hint from Geoff_Harcombe here

If anyone wants, the related document on firestore for the hint it is here
Method: projects.databases.documents.list  |  Firebase.

Thank you.

1 Like

Recycler view doesn’t get more data when you reach the end of the scroll, you would need to add your own logic (i.e. flows) that is called once you do. Unfortunately, I think the event which is meant to be triggered when reaching the end of the scroll is not working (@Mari, @Harri_Sarsa?). You would need to use a button linked to an API call with pagination, as you’re already trying.

Could you be more specific? I am not sure what you mean here.

1 Like

Hey Juan, thanks for replying!

I’ve come up with 3 potential solutions

  1. An ‘infinite list’ that just shows all the data like so…

    I am not too worried users will input more than 2,000 data in this document but I am worried of a potential crash if hundreds of data had to be loaded

2)A load more button where the “?pageSize={numberSetToVariable}” will be dynamic and so on click of the button, the request will multiply. Again, if a user has lots of data, in the end, it may lead to showing hundreds of data at once if a load more button keeps getting pressed.

  1. Some sort of next page button where just chunks of data will be shown. My method would be to use the GET request to get all data. COUNT it and divide it by how much data I want to show each time to get the number of pages (or next page button clicks). e.g. my data has 200 documents and I want to show 20 each time, that’s 10 pages (all these will change so will be dynamic using formulas). The thing I’m stuck on is i don’t know how to get the next data along. For firestore, it gets 20 documents at a time (without pageSize query), how would I get the documents 21-40 then 41-60 etc.?

I can see this method here rest - How to fetch all documents from a collection using Firestore API? - Stack Overflow but not understanding how to get the nextPageToken to begin with here
Method: projects.databases.documents.list  |  Firebase

Which method do you think is best? How would you tackle pagination in your project?

I’m currently reading this so more updates later :slight_smile:

1 Like

I’m new to AppGyver but I use Firebase a lot on other projects. To use pagination you have to use both PageSize and pageToken

You will find the token as the last property in the previous JSON response

Your http request would include something like this


Hope this helps.

1 Like

Hey Muneer!

Thanks for the insight :slight_smile: Is there something I’m missing? the last properties of my JSON response are

using the GET method.

I’ve also tried this as apparently that’s how I would get a nextPageToken ??Method: projects.databases.documents.listCollectionIds  |  Firestore
but ended up creating a new document instead.

1 Like

It should be the item just after the document array retrieved. I worked with it with JavaScript but as I mentioned I’m new to this platform.

This is the key nextPageToken

1 Like

Thank you Muneer and Juan!

After looking into it and watching this video"

I’m going to go with method two.

For anyone else who’d like to know:
This method is according to the purposes of the app and so will vary.

the pageSize is dynamic and will change depending on a [load more button]. But the real key here is the sub-collection is also dynamic so you don’t get too much data. The data is automatically split up in years so that you’re not getting the user’s whole data history from the parent collection.
When a page is opened, I’ve set pageSize to 50 and a pageVars.pageCount which counts the number of times the [Load more button] is pressed and would serve as the multiplier to the initial pageSize to 1.
When the [load more button] is pressed an if flow function is triggered

If the number of data is less than 50 times count of button pressed, then it will not get more data, if it is equal that then it will issue a GET collection and increase pageVars.pageCount by 1
If there is anything you think I could change please let me know!

pros: easy
cons: calling data you already have + new ones each time which if calling too many times kind of defeats the purpose of pagination

I might go back to this in the future but for now this serves my purposes fine.