How do I know where many SnapshotListener
of a different collections has been completed?
Take an example of trying to retrieve a user from a user collection, a team from the teams collection, and a coach from the coaches collection.
I want to make the activity "active" only when i got all the data that I am looking for.
For example:
firebaseFirestore.collectionGroup("users").whereEqualTo("user_id", currentUser.getId()).addSnapshotListener(this, new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots, @Nullable FirebaseFirestoreException e) {
// getting the user
}
firebaseFirestore.collectionGroup("teams").whereEqualTo("team_id", currentTeam.getId()).addSnapshotListener(this, new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots, @Nullable FirebaseFirestoreException e) {
// getting the team
}
firebaseFirestore.collectionGroup("coachs").whereEqualTo("coach_id", currentCoach.getId()).addSnapshotListener(this, new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot queryDocumentSnapshots, @Nullable FirebaseFirestoreException e) {
// getting the coach
}
How do I make sure that only when I got all the three i will make my activity "enable"?