Skip to content

Instantly share code, notes, and snippets.

@bikashthapa01
Last active September 5, 2020 11:36
Show Gist options
  • Save bikashthapa01/ae207b2e2b2cf7945f4f11ae540108db to your computer and use it in GitHub Desktop.
Save bikashthapa01/ae207b2e2b2cf7945f4f11ae540108db to your computer and use it in GitHub Desktop.
CollectionReference colRef = fStore.collection("Users");
colRef.get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if(task.isSuccessful()){
for(QueryDocumentSnapshot userData : task.getResult()){
//Log.d(TAG, "onComplete: " + userData.getData());
User user = new User();
user.setName(userData.getString("name"));
user.setEmail(userData.getString("email"));
user.setProfileUrl(userData.getString("profileUrl"));
allUsers.add(user);
}
//Log.d(TAG, "onCreateView: " + allUsers.get(0).getName());
adapter = new UserListAdapter(allUsers);
friendList.setAdapter(adapter);
}
}
});
DocumentReference docRef = fStore.collection("Users").document(fAuth.getCurrentUser().getUid());
docRef.addSnapshotListener(new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(@Nullable DocumentSnapshot value, @Nullable FirebaseFirestoreException error) {
if(value != null && value.exists()){
Log.d(TAG, "onEvent: " + value.getData());
}else {
Log.d(TAG, "onEvent: Data is Null");
}
if(error != null){
Log.w(TAG, "onEvent: Listen Failed. ", error);
return;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment