【问题标题】:The new paging library can also work with Firebase?新的分页库也可以与 Firebase 一起使用?
【发布时间】:2019-01-15 18:54:08
【问题描述】:

新的paging library 也可以与 Firebase 实时数据库或 Cloud Firestore 一起使用?我知道它是异步工​​作的,但有什么方法可以与实时数据库一起工作?

谢谢!

【问题讨论】:

标签: android firebase firebase-realtime-database google-cloud-firestore android-architecture-components


【解决方案1】:

关于 Firestore,你可以使用FirestorePagingAdapter:

FirestorePagingAdapter 通过在页面中加载文档将查询绑定到RecyclerView。这会产生一种节省时间和内存的绑定。

FirestorePagingAdapter 构建在 Android Paging Support Library 之上。

【讨论】:

  • 感谢您的回答。如果我们使用FirestorePagingAdapter,我们会失去实时功能,对吗?
  • @IoanaP。彼得是对的,您可以使用FirestorePagingAdapter 进行分页,而且您也猜对了您将失去实时功能。请参阅来自 post 的 Frank 的回答,他解释说 FirestorePagingAdapter 旨在获取数据,而不是侦听实时更新。
  • @IoanaP。如果您想使用实时功能,您应该使用FirestoreRecyclerAdapter,将 Query 绑定到 RecyclerView 并响应所有实时事件,包括添加、删除、移动或更改的项目。最好用于小型结果集,因为所有结果都是一次加载的。如果您有较大的结果集,您可以以小块的形式加载数据,为此我建议您从 post 中查看我的答案。
  • 谢谢彼得,谢谢亚历克斯! FirestoreRecyclerAdapter 是我要找的。​​span>
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-12-17
  • 2018-06-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-07
  • 1970-01-01
相关资源
最近更新 更多