【发布时间】:2019-12-23 21:55:04
【问题描述】:
我正在使用 FirestorePagingAdapter 来显示 Firestore 中的项目。加载数据时调用哪个方法?像 FirestoreRecyclerAdapter 在加载数据时会覆盖一个方法 onDataChanged()。
FirestoreRecyclerAdapter adapter = new FirestoreRecyclerAdapter<Chat, ChatHolder>(options) {
// ...
@Override
public void onDataChanged() {
// Called each time there is a new query snapshot. You may want to use this method
// to hide a loading spinner or check for the "no documents" state and update your UI.
// ...
}
@Override
public void onError(FirebaseFirestoreException e) {
// Called when there is an error getting a query snapshot. You may want to update
// your UI to display an error message to the user.
// ...
}
};
相当于 FirestorePagingAdapter 中的 onDataChanged()。我试过onCurrentListChanged(),但currentList的大小始终为零。
@Override
public void onCurrentListChanged(@Nullable PagedList<DocumentSnapshot> currentList) {
if(currentList.size()==0){
Log.e(TAG, "onCurrentListChanged: no data");
emptyBoxAnimation.setVisibility(View.VISIBLE);
}
}
【问题讨论】:
标签: android firebase google-cloud-firestore firebaseui