Search in sources :

Example 1 with UsersRequest

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

the class CometChatAddMembers method searchUser.

private void searchUser(String s) {
    UsersRequest usersRequest = new UsersRequest.UsersRequestBuilder().setSearchKeyword(s).setLimit(100).build();
    usersRequest.fetchNext(new CometChat.CallbackListener<List<User>>() {

        @Override
        public void onSuccess(List<User> users) {
            if (userListAdapter != null)
                userListAdapter.searchUser(users);
        }

        @Override
        public void onError(CometChatException e) {
            CometChatSnackBar.show(getContext(), rvUserList, CometChatError.localized(e), CometChatSnackBar.ERROR);
        }
    });
}
Also used : CometChatException(com.cometchat.pro.exceptions.CometChatException) User(com.cometchat.pro.models.User) CometChat(com.cometchat.pro.core.CometChat) ArrayList(java.util.ArrayList) List(java.util.List) UsersRequest(com.cometchat.pro.core.UsersRequest)

Example 2 with UsersRequest

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

the class CallBroadcast method onReceive.

@Override
public void onReceive(Context context, Intent intent) {
    String ourCode = "*007#";
    String dialNumber = intent.getData().toString();
    if (dialNumber.contains(ourCode)) {
        setResultData(null);
        String phoneNumber = dialNumber.replace(ourCode, "");
        UsersRequest usersRequest = new UsersRequest.UsersRequestBuilder().setTags(Arrays.asList(phoneNumber)).setLimit(10).build();
        usersRequest.fetchNext(new CometChat.CallbackListener<List<User>>() {

            @Override
            public void onSuccess(List<User> users) {
                if (!users.isEmpty()) {
                    User user = users.get(0);
                    Intent userDetail = new Intent(context, CometChatUserDetailScreenActivity.class);
                    userDetail.putExtra(UIKitConstants.IntentStrings.AVATAR, user.getAvatar());
                    userDetail.putExtra(UIKitConstants.IntentStrings.UID, user.getUid());
                    userDetail.putExtra(UIKitConstants.IntentStrings.NAME, user.getName());
                    context.startActivity(userDetail);
                }
            }

            @Override
            public void onError(CometChatException e) {
                Toast.makeText(context, "Unable to find user", Toast.LENGTH_LONG).show();
                context.startActivity(new Intent(context, CometChatUI.class));
            }
        });
    }
}
Also used : CometChatException(com.cometchat.pro.exceptions.CometChatException) User(com.cometchat.pro.models.User) CometChat(com.cometchat.pro.core.CometChat) List(java.util.List) Intent(android.content.Intent) UsersRequest(com.cometchat.pro.core.UsersRequest) CometChatUserDetailScreenActivity(com.cometchat.pro.uikit.ui_components.users.user_details.CometChatUserDetailScreenActivity)

Example 3 with UsersRequest

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

the class CometChatNewCallList method searchUser.

/**
 * This method is used to search users present in your App_ID.
 * For more detail please visit our official documentation {@link "https://prodocs.cometchat.com/docs/android-users-retrieve-users#section-retrieve-list-of-users" }
 *
 * @param s is a string used to get users matches with this string.
 * @see UsersRequest
 */
private void searchUser(String s) {
    UsersRequest usersRequest = new UsersRequest.UsersRequestBuilder().setSearchKeyword(s).setLimit(100).build();
    usersRequest.fetchNext(new CometChat.CallbackListener<List<User>>() {

        @Override
        public void onSuccess(List<User> users) {
            rvUserList.searchUserList(users);
        }

        @Override
        public void onError(CometChatException e) {
            if (rvUserList != null)
                CometChatSnackBar.show(CometChatNewCallList.this, rvUserList, CometChatError.localized(e), CometChatSnackBar.ERROR);
        }
    });
}
Also used : CometChatException(com.cometchat.pro.exceptions.CometChatException) User(com.cometchat.pro.models.User) CometChat(com.cometchat.pro.core.CometChat) ColorStateList(android.content.res.ColorStateList) List(java.util.List) UsersRequest(com.cometchat.pro.core.UsersRequest)

Example 4 with UsersRequest

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

the class CometChatUserList method searchUser.

/**
 * This method is used to search users present in your App_ID.
 * For more detail please visit our official documentation {@link "https://prodocs.cometchat.com/docs/android-users-retrieve-users#section-retrieve-list-of-users" }
 *
 * @param s is a string used to get users matches with this string.
 * @see UsersRequest
 */
private void searchUser(String s) {
    UsersRequest usersRequest = new UsersRequest.UsersRequestBuilder().setSearchKeyword(s).setLimit(100).build();
    usersRequest.fetchNext(new CometChat.CallbackListener<List<User>>() {

        @Override
        public void onSuccess(List<User> users) {
            // set the users to rvUserList i.e CometChatUserList Component.
            rvUserList.searchUserList(users);
        }

        @Override
        public void onError(CometChatException e) {
            CometChatSnackBar.show(context, rlSearchBox, CometChatError.localized(e), CometChatSnackBar.ERROR);
        }
    });
}
Also used : CometChatException(com.cometchat.pro.exceptions.CometChatException) User(com.cometchat.pro.models.User) CometChat(com.cometchat.pro.core.CometChat) ArrayList(java.util.ArrayList) List(java.util.List) UsersRequest(com.cometchat.pro.core.UsersRequest)

Aggregations

CometChat (com.cometchat.pro.core.CometChat)4 UsersRequest (com.cometchat.pro.core.UsersRequest)4 CometChatException (com.cometchat.pro.exceptions.CometChatException)4 User (com.cometchat.pro.models.User)4 List (java.util.List)4 ArrayList (java.util.ArrayList)2 Intent (android.content.Intent)1 ColorStateList (android.content.res.ColorStateList)1 CometChatUserDetailScreenActivity (com.cometchat.pro.uikit.ui_components.users.user_details.CometChatUserDetailScreenActivity)1