Search code examples
androidfirebaseandroid-recyclerviewfirebase-realtime-databasefirebaseui

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.


Solution

  • 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.