How to refresh data in a Firestore Paging Adapter using Swipe Refresh Layout

蓝咒 提交于 2021-02-05 08:58:26

问题


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

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

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


回答1:


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.

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()



来源:https://stackoverflow.com/questions/53360442/how-to-refresh-data-in-a-firestore-paging-adapter-using-swipe-refresh-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!