You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using FirebaseIndexRecyclerAdapter and 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(!)
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.
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.
Steps to reproduce:
Set new FirebaseIndexRecyclerAdapter to a RecyclerView
Override onChildChanged
Call getItemCount inside
Observed Results:
It returns 0 always
Expected Results:
Should return the data child actual count
Relevant Code:
Thanks
The text was updated successfully, but these errors were encountered:
@Shirane85 Yeah, don't rely on onDataChanged when using the index adapters pre v2.0; they're completely broken. This is fixed in v2.0 which will be coming out soon.
If you really need onDataChanged, I'm happy to get you setup with the latest v2.0 build, just ask. 😄
Step 2: Describe your environment
Step 3: Describe the problem:
I'm using FirebaseIndexRecyclerAdapter and 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(!)
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.
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.
Steps to reproduce:
Observed Results:
Expected Results:
Relevant Code:
Thanks
The text was updated successfully, but these errors were encountered: