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);
}
});
}
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));
}
});
}
}
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);
}
});
}
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);
}
});
}
Aggregations