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?
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?
You can create a custom Adapter class to accomplish this but its not fully optimal. See: https://stackoverflow.com/a/53235783/683658