Reputation: 2295
I'm using FirebaseIndexRecyclerAdapter
which gets a keyRef and dataRef and is very helpful with getting all dataRef's children which their keys exists as children in keyRef.
The data is being displayed correctly but if i'm overriding onDataChanged
for hiding a progress bar and/or displaying an empty state depends on the itemsCount (Something which i've already done with FirebaseRecyclerAdapter
and works as expected) but getItemCount
always return 0(!)
private class MYAdapter extends FirebaseIndexRecyclerAdapter<Item, ItemHolder> {
.
.
@Override
protected void onDataChanged() {
super.onDataChanged();
// getItemCount() == 0 here always
}
.
.
}
I've investigate it and the reason is that FirebaseIndexRecyclerAdapter
is using FirebaseIndexArray
which is overriding getItemCount
and return mDataSnapshots.size()
but the data was not loaded yet - the onDataChanged
was called because the keyRef loaded - and indeed i can see in debug that the keys are loaded (with the correct count) but unfortunately they are private so i can't use them to get the count.
I know i can override onChildChanged
and then call getItemCount
and get the correct count (which i've done) but still i can't know if there are no items and i need to display the empty state.
Using com.firebaseui:firebase-ui:1.2.0
Is there something i'm missing?
Note - I know i can manage my own count (child) beside the data and just load it before setting the adapter but i'm saving this as a last resort.
Thanks!
Upvotes: 2
Views: 497