use of com.tutuanle.chatapp.adapters.Users_Adapter in project Chat-app by TuTuanLe.
the class ChatFragment method getUSer.
private void getUSer() {
loading(true);
FirebaseFirestore database = FirebaseFirestore.getInstance();
database.collection(Constants.KEY_COLLECTION_USERS).get().addOnCompleteListener(task -> {
loading(false);
String currentUserId = preferenceManager.getString(Constants.KEY_USER_ID);
if (task.isSuccessful() && task.getResult() != null) {
List<User> users = new ArrayList<>();
for (QueryDocumentSnapshot queryDocumentSnapshot : task.getResult()) {
if (currentUserId.equals(queryDocumentSnapshot.getId())) {
continue;
}
User user = new User();
user.setName(queryDocumentSnapshot.getString(Constants.KEY_NAME));
user.setEmail(queryDocumentSnapshot.getString(Constants.KEY_EMAIL));
user.setProfileImage(queryDocumentSnapshot.getString(Constants.KEY_IMAGE));
user.setToken(queryDocumentSnapshot.getString(Constants.KEY_FCM_TOKEN));
user.setUid(queryDocumentSnapshot.getId());
user.setAvailability(queryDocumentSnapshot.getLong(Constants.KEY_AVAILABILITY));
users.add(user);
}
if (users.size() > 0) {
Users_Adapter users_adapter = new Users_Adapter(users, mainScreenActivity);
RecyclerView temp = view.findViewById(R.id.userRecyclerView);
temp.setAdapter(users_adapter);
temp.setVisibility(View.VISIBLE);
} else {
showErrorMessage();
}
}
});
}
Aggregations