如何使用滑动刷新布局刷新Firestore分页适配器中的数据

如何使用滑动刷新布局刷新Firestore分页适配器中的数据

本文介绍了如何使用滑动刷新布局刷新Firestore分页适配器中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个我想从Firestore中获取数据并在用户滚动时将其显示在recyclerview中的应用程序.

I am building an app that i would like to fetch data from Firestore and display it in recyclerview as the user scrolls.

我正在使用FirestorePagingAdapter,如此处所述: https://github.com/firebase/FirebaseUI-Android/tree/master/firestore#using-the-firestorepagingadapter .

I am using FirestorePagingAdapter as described here: https://github.com/firebase/FirebaseUI-Android/tree/master/firestore#using-the-firestorepagingadapter.

此适配器不侦听数据库中的实时更改,如何使用swipeRefreshLayout手动强制刷新?

This adapter does not listen for realtime changes in the database, how do I manually force a refresh using swipeRefreshLayout?

推荐答案

FirestorePagingAdapter 会在显示新页面时从数据库中重新加载数据.但是除此之外,它没有内置的刷新数据的方法.

The FirestorePagingAdapter will load the data fresh from the database whenever it shows a new page. But beyond that it has no built-in way to refresh the data.

如果要加载当前页面的最新数据,则必须在滑动处理程序中创建一个新的 FirestorePagingAdapter 实例.该代码将与您最初实例化该适配器的方式相同.不要忘记拨打 stopListening()

If you want to load fresh data for the current page, you will have to create a new FirestorePagingAdapter instance in your swipe handler. The code will be the same as how you initially instantiate that adapter. Don't forget to call stopListening()

这篇关于如何使用滑动刷新布局刷新Firestore分页适配器中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 10:20