Is there a way for passing a different view if there is no data? Or does this require a second data check up outside de adapter
@ismaelaarab this is a good feature request and something that I have implemented in my own apps many times on top of FirebaseUI. It would most likely take the form of a simplified AdapterDataObserver that works with Firebase.
I will put this on the Enhancements list and target it for a future release. If you have a good solution, always feel free to send a PR.
I am also running into needing this for my application. I think a simple solution would be just to make an interface for onDataChanged and call it at the end of mSnapshot's data change listener...Actually for that matter we could just add another FirebaseArray.OnChangedListener that is called at the end of the method so that the notifies are done properly but then the developer has all the data needed to make changes to the UI based on the update
Agree on this one.
Somthing similar to LoaderManager.LoaderCallbacks would be very useful. It would be very useful if we know when the list(FirebaseListAdapter/FirebaseRecyclerAdapter) is finished loading.
This is exactly what is holding me back right now. Basically there's a few scenarios that are common to a lot of my lists: Empty (size 0) and Error(impossible to get any data from network or cache.) I'd be really really happy to see this implemented. In my case I hide the recyclerView to show something else.
@Sottti @winstonma Here's a trick you could use in the meantime.
If you attach a ValueEventListener to the same DatabaseReference that you're passing into the RecyclerView you can use it as an indication of when the load is done. You'll get the onDataChange callback in the ValueEventListener and this is guaranteed to happen after all of the child events have been propagated to the RecyclerView.
So if you get onDataChange and the RecyclerView still has 0 items you can show your "no items" message or do something similar while being confident that the initial load is complete.
Thanks @samtstern
I saw many workarounds and it works. But it would be great if the features like setEmptyView and OnLoadFinished is implemented so no one need to StackOverflow and make apps easier to build.
Thanks for the effort. In the meantime I will stick with your solution.
@winstonma agree that some sort of OnLoadFinished callback would be a good feature. Hopefully we will get to it in a coming release.
A fix for this issue has been released in version 1.1.0
Thanks appreciated
Greetings.
I was waiting for this, is great thanks! Can I suggest adding it in the docs, took me awhile to find it in the demo app.
Thanks.
I dont understand hwo this works if the firebase adapter is not a nested class
@dri94
public class MyAdapter extends FirebaseRecyclerAdapter<MyHolder, MyModel> {}
You can create the holder as a nested class inside the MyAdapter class or as another class on its own file, anyway: the adapter needs the holder so always start for creating the holder.
After you extend your class alt+enter on anything red and should suggest you the missing methods and constructor to make it work.
Most helpful comment
Greetings.
I was waiting for this, is great thanks! Can I suggest adding it in the docs, took me awhile to find it in the demo app.
Thanks.