Search in sources :

Example 1 with UsersGCAdapter

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();
        }
    });
}
Also used : UsersGCAdapter(com.example.clown.adapter.UsersGCAdapter) FirebaseFirestore(com.google.firebase.firestore.FirebaseFirestore) User(com.example.clown.models.User) QueryDocumentSnapshot(com.google.firebase.firestore.QueryDocumentSnapshot)

Example 2 with UsersGCAdapter

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);
    }
}
Also used : UsersGCAdapter(com.example.clown.adapter.UsersGCAdapter) GroupChatAdapter(com.example.clown.adapter.GroupChatAdapter)

Aggregations

UsersGCAdapter (com.example.clown.adapter.UsersGCAdapter)2 GroupChatAdapter (com.example.clown.adapter.GroupChatAdapter)1 User (com.example.clown.models.User)1 FirebaseFirestore (com.google.firebase.firestore.FirebaseFirestore)1 QueryDocumentSnapshot (com.google.firebase.firestore.QueryDocumentSnapshot)1