I have this code that fetch data from specific sub-collection:
db.collection("groups").document(id.get(i)).collection("members")
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
id.add(document.getId());
Log.e(Tag, document.getId() + " => " + document.getData());
if (task.getResult().isEmpty()) {
Log.d(Tag, "onSuccess: LIST EMPTY");
return;
} else {
// Convert the whole Query Snapshot to a list
// of objects directly! No need to fetch each
// document.
Log.e(Tag, task.getResult() + "");
typeAll = task.getResult().toObjects(GroupMembers.class);
}
}
} else {
Log.e(Tag, "Error getting documents: ", task.getException());
}
But I need to call a method after fetching all the data by snapshots. How to achieve that? what should I test?