Skip to content

Instantly share code, notes, and snippets.

@RBonaventure
Last active December 22, 2017 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RBonaventure/12283d6115d9960421470dde949acc41 to your computer and use it in GitHub Desktop.
Save RBonaventure/12283d6115d9960421470dde949acc41 to your computer and use it in GitHub Desktop.
firestore-fetch-data
// @see Firebase Performance
Traces.start(Traces.COLLABORATORS_TIME);
// Fetch collaborators list from Firestore
Collaborator.getAll(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if(task.isSuccessful()) {
mCollaborators = task.getResult();
CollaboratorsAdapter.this.notifyDataSetChanged();
}
Traces.stop(Traces.COLLABORATORS_TIME);
}
});
// Collaborator.java#getAll
public static void getAll(OnCompleteListener<QuerySnapshot> listener) {
FirebaseFirestore.getInstance()
.collection(FirestoreCollections.RESOURCES).get().addOnCompleteListener(listener);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment