【发布时间】:2020-09-18 13:52:50
【问题描述】:
当我用whereGreaterThan 查询whereEqualTo 时:
productRef
.whereGreaterThan("discount",0)
.whereEqualTo("available", true)
.whereEqualTo("shopId", Pref.getSelectedShopId(activity))
.addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots,
@Nullable FirebaseFirestoreException e) {
for (DocumentChange doc : queryDocumentSnapshots.getDocumentChanges()) {
if (doc.getType() == DocumentChange.Type.ADDED) {
Product product = doc.getDocument().toObject(Product.class);
productList.add(product);
myAdapter.setData(productList);
myAdapter.notifyDataSetChanged();
}
}
}
});
我收到此错误:
java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法“java.util.List com.google.firebase.firestore.QuerySnapshot.getDocumentChanges()”
【问题讨论】:
-
你有这个查询的复合索引吗?
-
没有。我不使用
标签: android google-cloud-firestore