question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FirebaseArray in FirebaseListAdapter is not accessible from subclasses

See original GitHub issue

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.

Firebase itemRef = adapter.getRef(position);
itemRef.removeValue();

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.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
samtsterncommented, Jul 28, 2016

@pantos27 FirebaseRecyclerAdapter already exposes the methods you likely want:

    @Override
    public int getItemCount() {
        return mSnapshots.getCount();
    }

    public T getItem(int position) {
        return parseSnapshot(mSnapshots.getItem(position));
    }
0reactions
pantos27commented, Aug 3, 2016

@puf you’re right. @samtstern 's solution should do the work very

Thank you both!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Firebase list adapter doesn't work shows error.......when try to ...
When the migration is complete, you will access your Teams at stackoverflowteams.com, and they will no longer appear in the left sidebar on ......
Read more >
FirebaseListAdapter not pushing individual items for chat app
I am making a chat app on Android that uses google firebase to store messages that users write ... firebase ui dependency to...
Read more >
ПОЯСНЮВАЛЬНА ЗАПИСКА дипломної роботи Дніпро 2018
differences with working on large amounts of data. Methods of research. ... The application has no analogues with the described functions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found