use of com.example.clown.adapter.UsersGCAdapter in project Skool by NhatTruongK15.
the class GroupChatActivity method getUsers.
private void getUsers() {
loading(true);
FirebaseFirestore database = FirebaseFirestore.getInstance();
database.collection(Constants.KEY_COLLECTION_USERS).get().addOnCompleteListener(task -> {
loading(false);
String currentUserId = preferenceManager.getString(Constants.KEY_DOCUMENT_REFERENCE_ID);
if (task.isSuccessful() && task.getResult() != null) {
for (QueryDocumentSnapshot queryDocumentSnapshot : task.getResult()) {
if (currentUserId.equals(queryDocumentSnapshot.getId())) {
continue;
}
User user = new User();
user.name = queryDocumentSnapshot.getString(Constants.KEY_NAME);
user.email = queryDocumentSnapshot.getString(Constants.KEY_EMAIL);
user.image = queryDocumentSnapshot.getString(Constants.KEY_IMAGE);
user.token = queryDocumentSnapshot.getString(Constants.KEY_FCM_TOKEN);
user.id = queryDocumentSnapshot.getId();
users.add(user);
}
if (users.size() > 0) {
UsersGCAdapter usersGCAdapter = new UsersGCAdapter(users, GroupChatActivity.this);
binding.listFriend.setAdapter(usersGCAdapter);
binding.listFriend.setVisibility(View.VISIBLE);
} else {
showError();
}
} else {
showError();
}
});
}
use of com.example.clown.adapter.UsersGCAdapter in project Skool by NhatTruongK15.
the class GroupChatActivity method getUserForGroupList.
private void getUserForGroupList(List<User> user, int viewType) {
if (viewType == 0) {
GroupChatAdapter groupChatAdapter = new GroupChatAdapter(user, GroupChatActivity.this);
binding.listUserAdded.setAdapter(groupChatAdapter);
} else if (viewType == 1) {
UsersGCAdapter usersGCAdapter = new UsersGCAdapter(users, GroupChatActivity.this);
binding.listFriend.setAdapter(usersGCAdapter);
}
}
Aggregations