Вы должны сначала проверить, есть ли какие-либо данные в снимке или нет.так что проверяйте вот так.
mFirestore.collection("FeaturedDeal").whereEqualTo("title","Amazon India").limit(10).orderBy("priority", Query.Direction.ASCENDING).addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@javax.annotation.Nullable QuerySnapshot documentSnapshots, @javax.annotation.Nullable FirebaseFirestoreException e) {
if (e != null) {
Log.d(TAG, "Error : " + e.getMessage());
return;
}else if ( documentSnapshots != null) {
for (DocumentChange doc : documentSnapshots.getDocumentChanges()) {
if (doc.getType() == DocumentChange.Type.ADDED) {
String doc_id = doc.getDocument().getId();
FeaturedDeal featuredDeal =
doc.getDocument().toObject(FeaturedDeal.class).withDocId(doc_id);
featuredDeals.add(featuredDeal);
featuredDealAdapter.notifyDataSetChanged();
} else if (doc.getType() == DocumentChange.Type.MODIFIED) {
String docID = doc.getDocument().getId();
FeaturedDeal changedModel =
doc.getDocument().toObject(FeaturedDeal.class).withDocId(docID);
if (doc.getOldIndex() == doc.getNewIndex()) {
// Item changed but remained in same position
featuredDeals.set(doc.getOldIndex(), changedModel);
featuredDealAdapter.notifyItemChanged(doc.getOldIndex());
} else {
// Item changed and changed position
featuredDeals.remove(doc.getOldIndex());
featuredDeals.add(doc.getNewIndex(), changedModel);
featuredDealAdapter.notifyItemMoved(doc.getOldIndex(), doc.getNewIndex());
}
} else if (doc.getType() == DocumentChange.Type.REMOVED) {
// remove
featuredDeals.remove(doc.getOldIndex());
featuredDealAdapter.notifyItemRemoved(doc.getOldIndex());
}
}
}
}
});