-
Notifications
You must be signed in to change notification settings - Fork 1.9k
FirebaseArray in FirebaseListAdapter is not accessible from subclasses #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
In general we kept filtering data out of FirebaseUI until we're ready to implement that feature properly (see #15). The potential for problems is quite big if you start manipulating the FirebaseArray. For example: how would you deal with move operations or other operation that require looking up an item by its key? While these questions may not apply to your use-case, the library is made to work equally for all of them. How would you use the array in your custom adapter subclass? |
Hi Frank Knowing better Firebase than before I think one possible solution of my original problem would be to keep a reference on Firebase through index (ex: "card already seen") and update the original list checking always against the boolean "card already seen". Thanks! |
@puf I'm using a RecyclerView with a long list of items |
@pantos27 you should be able to track the row index of items by creating a Map<Integer,Object> and populating it whenever you get a call to Also the iOS comparison isn't exactly fair since Objective C doesn't really have access modification like Java has 😄 |
@samtstern interesting idea. |
@pantos27 @Override
public int getItemCount() {
return mSnapshots.getCount();
}
public T getItem(int position) {
return parseSnapshot(mSnapshots.getItem(position));
} |
@samtstern right you are! It's not not exactly what I need but it gave me an idea Thanks |
@pantos27 I like when someone asks a question I have a good answer for. You can get the key using this method from public DatabaseReference getRef(int position) {
return mSnapshots.getItem(position).getRef();
} So it looks like |
@samtstern Nice, but it's not retrieving by key. |
If you're trying to find the position of an item in the recycler view that If that is not what you're trying to do, it'll probably be easier to help On Thu, Jul 28, 2016 at 11:16 AM Amir A [email protected] wrote:
|
@puf you're right. Thank you both! |
Uh oh!
There was an error while loading. Please reload this page.
Situation
You have a mobile app with Firebase as backend
you would like to view all the items in firebase location as cards in UI
you would like to remove some items just from the UI
(imagine a UI like Tinder app where a user can remove a card from UI and see the other cards in the list, where cards are items in Firebase db but they are not deleted when removed from UI)
Problem with FirebaseListAdapter
I use the FirebaseListAdapter as explained in the tutorial and I can easily retrieve the items from firebase and display them in the UI.
I don't know how to remove items from UI without removing it from Firebase too. The code below remove items from the Adapter but also from firebase.
I think the only way to remove items from the adpater without removing the firebase reference is to have access to the FirebaseArray used in the FirebaseListAdapter.
Proposed solution ?
Have the FirebaseArray protected so that when implementing our CustomAdapter we can have access to the FirebaseArray and remove items from it.
The text was updated successfully, but these errors were encountered: