在从FirebaseRecyclerAdapter填充视图之前过滤数据 [英] Filtering data before populating view from FirebaseRecyclerAdapter

查看:161
本文介绍了在从FirebaseRecyclerAdapter填充视图之前过滤数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从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的开放式功能请求。请参阅 https://github.com/firebase/FirebaseUI-Android/issues/15

客户端过滤数据,意味着应用程序首先下载数据,然后不显示给用户。这是浪费,如果您的应用程序只下载它显示给他们的数据,大多数移动应用程序的用户会很感激。



最好的方法来处理显示的一个子集数据是以某种方式为数据建模,以便您可以直接访问要显示的数据子集,或使用 Firebase查询来限制检索到的数据


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填充视图之前过滤数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆