Search code examples
androidfirebaseandroid-recyclerviewfirebase-realtime-databasefirebaseui

Filter in FirebaseRecyclerViewAdapter


On that question ( how to implement a SetOnItemClickListener FirebaseRecyclerViewAdapter ) I learned how to use the FirebaseRecyclerViewAdapter to get the click of recycler view, perfect.

Now I need to filter RecyclerView items made with the FirebaseRecyclerViewAdapter. In my business rule listo of the items and the user can filter them.

If it was manual, a list adding the adapter I know, but as the FirebaseRecyclerViewAdapter is responsible to prepare / update the list, someone has a suggestion how to put a filter?


Solution

  • Client-side filtering is not supported in the current version of FirebaseUI. It's on the roadmap, but not planned yet: https://github.com/firebase/FirebaseUI-Android/issues/15.

    In the meantime, you can either use Firebase's built-in Query capabilities to limit the data. This has the advantage that only data matching the conditions will be downloaded from the server.

    A great example of how advanced you can make this, is the "friend search" feature in the ShoppingList++ app of the Udacity course Firebase Essentials for Android. You can find the crucial class here in Github, but I highly recommend taking the entire course to see how this works.