Is there anyway to create an endless scroller with

2019-05-24 14:42发布

I've been searching all over the internet, while there are ways to create an endless scroller, for simple recyclerviews, there aren't any for the firebase recyclerview adapter. If anyone has implemented this, please help!

1条回答
家丑人穷心不美
2楼-- · 2019-05-24 15:04

I was facing the same problem, and didn't find any solution for that But i achieved it. Won't call it a right solution but it gave me the desired output.

Lets take an example, i have a list of cars in my Firebase Database and i want to display that in my app. In my App, there is a button "Show All The Cars" which takes me to a new Activity where I have to display all the cars from my Firebase database.

Solution: At first I tried to load the Firebase data in my Second Activity which worked fine. But as the data increased, the RecyclerView started Jittering. So instead of retrieving the Firebase data in my Second Activity, I retrieved the Firebase data in my FirstActivity when the button was clicked (in a ArrayList). then after the complete data is retrieved, Intent was called, and I sent the Arraylist with my firebase data to the secondActivity as an Extra in Intent.

You can then retrieve your ArrayList and Apply the normal Endless recyclerView logic to the ArrayList.

The Other question i think would come up right now is How to check if the Firebase is done retrieving data ? (Again After a huge amount of research I found this)

Firebase events are not executed in sequence, the Value even is always executed last, So In my onClickListener i had two EventListeners

  1. OnChildEventListener (too load my actual data)
  2. addListenerForSingleValueEvent (this would be executed last)

So now, writing code inside addListenerForSingleValueEvent() would be executed last (The Intent with Arraylist as an Extra)

I don't know if this answered your Question, but I hope this helps.

查看更多
登录 后发表回答