Last active
September 5, 2020 11:36
-
-
Save bikashthapa01/ae207b2e2b2cf7945f4f11ae540108db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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