Search in sources :

Example 1 with GroupMembersRequest

use of com.cometchat.pro.core.GroupMembersRequest in project android-java-chat-push-notification-app by cometchat-pro.

the class CometChatMessageList method getMember.

/**
 * This method is used to get Group Members and display names of group member.
 *
 * @see GroupMember
 * @see GroupMembersRequest
 */
private void getMember() {
    GroupMembersRequest groupMembersRequest = new GroupMembersRequest.GroupMembersRequestBuilder(Id).setLimit(30).build();
    groupMembersRequest.fetchNext(new CometChat.CallbackListener<List<GroupMember>>() {

        @Override
        public void onSuccess(List<GroupMember> list) {
            String[] s = new String[0];
            if (list != null && list.size() != 0) {
                s = new String[list.size()];
                for (int j = 0; j < list.size(); j++) {
                    s[j] = list.get(j).getName();
                }
            }
            setSubTitle(s);
        }

        @Override
        public void onError(CometChatException e) {
            Log.d(TAG, "Group Member list fetching failed with exception: " + e.getMessage());
            Toast.makeText(context, e.getMessage(), Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : CometChatException(com.cometchat.pro.exceptions.CometChatException) GroupMember(com.cometchat.pro.models.GroupMember) GroupMembersRequest(com.cometchat.pro.core.GroupMembersRequest) CometChat(com.cometchat.pro.core.CometChat) ColorStateList(android.content.res.ColorStateList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with GroupMembersRequest

use of com.cometchat.pro.core.GroupMembersRequest in project android-java-chat-push-notification-app by cometchat-pro.

the class CometChatGroupMemberList method searchUser.

/**
 * This method is used to perform search operation on list of group members.
 *
 * @param s is a String which is used to search group members.
 *
 * @see GroupMembersRequest
 */
private void searchUser(String s) {
    GroupMembersRequest groupMembersRequest = new GroupMembersRequest.GroupMembersRequestBuilder(guid).setSearchKeyword(s).setLimit(10).build();
    groupMembersRequest.fetchNext(new CometChat.CallbackListener<List<GroupMember>>() {

        @Override
        public void onSuccess(List<GroupMember> groupMembers) {
            if (groupMemberListAdapter != null) {
                List<GroupMember> filterlist = new ArrayList<>();
                for (GroupMember gmember : groupMembers) {
                    if (gmember.getScope().equals(CometChatConstants.SCOPE_PARTICIPANT)) {
                        filterlist.add(gmember);
                    }
                }
                groupMemberListAdapter.searchGroupMembers(filterlist);
            }
        }

        @Override
        public void onError(CometChatException e) {
            CometChatSnackBar.show(context, rvGroupMemberList, CometChatError.localized(e), CometChatSnackBar.ERROR);
            Log.e(TAG, "onError: " + e.getMessage());
        }
    });
}
Also used : CometChatException(com.cometchat.pro.exceptions.CometChatException) GroupMember(com.cometchat.pro.models.GroupMember) GroupMembersRequest(com.cometchat.pro.core.GroupMembersRequest) CometChat(com.cometchat.pro.core.CometChat) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

CometChat (com.cometchat.pro.core.CometChat)2 GroupMembersRequest (com.cometchat.pro.core.GroupMembersRequest)2 CometChatException (com.cometchat.pro.exceptions.CometChatException)2 GroupMember (com.cometchat.pro.models.GroupMember)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ColorStateList (android.content.res.ColorStateList)1