如何更新FirebaseRecyclerAdapter的查询 [英] How to update a FirebaseRecyclerAdapter's query
问题描述
如果我有查询
,我将它设置为 FirebaseRecyclerAdapter
。
$ b 然后,我要不断创建一个新的
Query
并更新 FirebaseRecyclerAdapter
。 EG:
query = database.orderByChild(child);
query2 = database.orderByChild(child2);
adapter = new FirebaseRecyclerAdapter< ...>(...,...,...,query){
...
}
现在,3秒钟后,我正在查找更改查询的方法。与此类似:
adapter.setQuery(query2);
有没有现成的方法? Firebase数据库查询是不可变的:或者是Firebase,就像往常一样,懒得连工作都没有? 解决方案
Firebase数据库查询是不可变的:现有查询的属性。
由于FirebaseUI中的适配器大多是底层数据结构的反映,因此我们没有添加选项来更改现有适配器的查询当我创建一个新的查询时,我还创建了一个新的适配器,并将 绑定到(列表或回收者)视图。
您看到在现有适配器下替换新查询的新适配器的优势吗?
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?
这篇关于如何更新FirebaseRecyclerAdapter的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!