Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase android how to prevent FirebaseRecyclerAdapter automatically updating?

I have a FirebaseRecyclerAdapter which I do not want to keep updating the RecyclerView. This is because I have it so it populates the view with items based on how many 'views' they have in the database. The problem is, if other people view the items, the list you see in the app will keep changing order. Is there a way to stop the recycler adapter from constantly listening for data changes or will I have to go about this another way?

Any help is greatly appreciated, thanks.

like image 898
Alex Boullé Avatar asked May 26 '16 15:05

Alex Boullé


1 Answers

The adapters in FirebaseUI are live-bound to the data at the Query/DatabaseReference that you construct them with. There is no way to turn this behavior off in the adapter.

But you can easily create a ValueEventListener that populates a static List<T> and feeds that into an ArrayAdapter.

like image 76
Frank van Puffelen Avatar answered Oct 20 '22 20:10

Frank van Puffelen