有没有一种方法可以使用Firebase UI RecyclerView过滤数据? [英] Is there a way to filter data with Firebase UI RecyclerView?

查看:64
本文介绍了有没有一种方法可以使用Firebase UI RecyclerView过滤数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Firebase UI FirestorePagingAdapter,我具有一个posts的集合,并且我希望过滤不是来自当前用户的帖子,并按timestamp

I'm using the Firebase UI FirestorePagingAdapter, i have a colletion of posts and i want to filter the post that are not from the current user and order them by timestamp

我尝试这样做,但出现不平等错误:

I tried doing this but i get inequality error:

override fun getPostFromLocation(viewLifecycleOwner:LifecycleOwner, location:String) :FirestorePagingOptions<Post>{
    val query = firestore.collection(POST_COLLECTION)
        .orderBy("timestamp", Query.Direction.DESCENDING)
        .whereNotEqualTo("uid",auth.currentUser?.uid)
    return FirestorePagingOptions.Builder<Post>()
        .setLifecycleOwner(viewLifecycleOwner)
        .setQuery(query, pagingConfig, Post::class.java)
        .build()
}

我可以过滤结果吗?

推荐答案

如果要使用Firebase UI来管理RecyclerView,则必须使用查询中的其他条件来过滤结果.

If you want to use Firebase UI to manage the RecyclerView, you will have to filter the results with another condition on the query.

如果无法使查询完全返回所需的内容,则将无法使用Firebase UI.相反,您将必须手动执行查询,编写代码以过滤结果,然后使用您自己的适配器将其应用于RecyclerView.

If you can't make the query return exactly what you want, you will not be able to use Firebase UI. Instead, you will have to manually perform the query, write code to filter the results, and apply those to a RecyclerView with your own adapter.

这篇关于有没有一种方法可以使用Firebase UI RecyclerView过滤数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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