3

If I have a Query a, and I'm setting it to a FirebaseRecyclerAdapter.

Then, I want to constantly create a new Query and update the FirebaseRecyclerAdapter.

E.G:

query = database.orderByChild("child");
query2 = database.orderByChild("child2"); 
adapter = new FirebaseRecyclerAdapter<...>(...,...,...,query){
   ...
}

Now, after 3 seconds, I'm looking for a method to change the query. Similar to this:

adapter.setQuery(query2);

Is there an existing method for this? Or was Firebase, like always, too lazy to even work on this?

Ali Bdeir
  • 4,151
  • 10
  • 57
  • 117

2 Answers2

0

Firebase Database queries are immutable: you cannot change the properties of an existing query.

Since the adapters in FirebaseUI are mostly a reflection of the underlying data structure, we have not added the option to change the query for an existing adapter either.

When I create a new query, I also create a new adapter and tie that to the (list or recycler) view.

What advantage do you see of replacing the query under the existing adapter over creating a new adapter for the new query?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • The advantage is I don't have to wait for Firebase to implement its filtering without wasting bandwidth. – Ali Bdeir Dec 02 '16 at 05:10
  • puf the clear advantage is runtime filtering. Take SearchView for example, if I can tie the search phrase to a new/updated query I can achieve filtering. Please update the post in case you have added client side filtering. – RonTLV Nov 04 '18 at 07:04
0

You can create a custom Adapter class to accomplish this but its not fully optimal. See: https://stackoverflow.com/a/53235783/683658

Marco RS
  • 8,145
  • 3
  • 37
  • 45