问题描述
从FireChat应用程序中引用我在我的应用程序中使用了FirebaseRecyclerAdapter,它工作正常,但是我需要过滤与特定用户ID相同的数据。在populateView if
mFirebaseAdapter = new FirebaseRecyclerAdapter< Tags,TagsViewHolder>> ;(
Tags.class,
R.layout.item_message,
TagsViewHolder.class,
mFirebaseDatabaseReference.child(tags)){
@Override
protected void populateViewHolder(TagsViewHolder viewHolder,Tags tags,int position){
mProgressBar.setVisibility(ProgressBar.INVISIBLE);如果((tags.getUserid())。equals(mFirebaseUser.getUid()))
viewHolder.tagTextView.setText(tags.getTagname());
}
};
有什么方法可以在创建视图之前对其进行过滤?
我的POJO类是:
public class Tags {
私人字符串用户ID;
私人字符串标记名;
私有HashMap< String,Object> timestampCreated;
$ b $ public标签(){
}
$ b $公共标签(String userid,String tagname,HashMap< String,Object> timestampCreated){
this。 userid = userid;
this.tagname = tagname;
this.timestampCreated = timestampCreated;
}
public String getUserid(){
return userid;
}
public String getTagname(){
return tagname;
}
public HashMap< String,Object> getTimestampCreated(){
return timestampCreated;
$ b
客户端过滤是针对FirebaseUI的开放式功能请求。请参阅。
Taking reference from FireChat app I used FirebaseRecyclerAdapter in my app, it is working fine but I need to filter data which equals to specific user ID.
In populateView if I does that data is getting filtered but a blank recycler Item item is also getting created.
mFirebaseAdapter = new FirebaseRecyclerAdapter<Tags, TagsViewHolder>(
Tags.class,
R.layout.item_message,
TagsViewHolder.class,
mFirebaseDatabaseReference.child("tags")) {
@Override
protected void populateViewHolder(TagsViewHolder viewHolder, Tags tags, int position) {
mProgressBar.setVisibility(ProgressBar.INVISIBLE);
if((tags.getUserid()).equals(mFirebaseUser.getUid()))
viewHolder.tagTextView.setText(tags.getTagname());
}
};
Is there any way I can filter it before a view gets created?
my POJO class is:
public class Tags {
private String userid;
private String tagname;
private HashMap<String, Object> timestampCreated;
public Tags() {
}
public Tags(String userid, String tagname, HashMap<String, Object> timestampCreated) {
this.userid = userid;
this.tagname = tagname;
this.timestampCreated = timestampCreated;
}
public String getUserid() {
return userid;
}
public String getTagname() {
return tagname;
}
public HashMap<String, Object> getTimestampCreated() {
return timestampCreated;
}
}
Thank you!
解决方案 Client-side filtering is an open feature request for FirebaseUI. See https://github.com/firebase/FirebaseUI-Android/issues/15.
Client-side filtering of data, means that the app first download data and then doesn't show it to the user. This is wasteful and most users of mobile apps will appreciate it if your app only downloads data that it shows to them.
The best ways to deal with displaying a subset of the data is to either model the data in a way so that you can directly access the subset of data that you want to display, or to use Firebase queries to limit the data that is retrieved.
这篇关于在从FirebaseRecyclerAdapter填充视图之前过滤数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!