use of com.cometchat.pro.exceptions.CometChatException in project android-java-chat-push-notification-app by cometchat-pro.
the class CometChatUserDetailScreenActivity method kickGroupMember.
private void kickGroupMember() {
ProgressDialog progressDialog = ProgressDialog.show(this, null, String.format(getResources().getString(R.string.user_removed_from_group), userName.getText().toString(), groupName));
CometChat.kickGroupMember(uid, guid, new CometChat.CallbackListener<String>() {
@Override
public void onSuccess(String s) {
progressDialog.dismiss();
addBtn.setText(String.format(getResources().getString(R.string.add_in), groupName));
addBtn.setVisibility(View.VISIBLE);
isAlreadyAdded = false;
}
@Override
public void onError(CometChatException e) {
progressDialog.dismiss();
if (tvBlockUser != null)
CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, tvBlockUser, CometChatError.localized(e), CometChatSnackBar.ERROR);
}
});
}
use of com.cometchat.pro.exceptions.CometChatException in project android-java-chat-push-notification-app by cometchat-pro.
the class CometChatUserDetailScreenActivity method addMember.
private void addMember() {
ProgressDialog progressDialog = ProgressDialog.show(this, null, String.format(getResources().getString(R.string.user_added_to_group), userName.getText().toString(), groupName));
List<GroupMember> userList = new ArrayList<>();
userList.add(new GroupMember(uid, CometChatConstants.SCOPE_PARTICIPANT));
CometChat.addMembersToGroup(guid, userList, null, new CometChat.CallbackListener<HashMap<String, String>>() {
@Override
public void onSuccess(HashMap<String, String> stringStringHashMap) {
Log.e(TAG, "onSuccess: " + uid + "Group" + guid);
progressDialog.dismiss();
// if(tvBlockUser!=null) {
// CometChatSnackBar.show(CometChatUserDetailScreenActivity.this,
// tvBlockUser, String.format(getResources().getString(R.string.user_added_to_group), userName.getText().toString(), groupName),
// CometChatSnackBar.SUCCESS);
// }
addBtn.setText(String.format(getResources().getString(R.string.remove_from_group), groupName));
isAlreadyAdded = true;
}
@Override
public void onError(CometChatException e) {
progressDialog.dismiss();
CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, historyRv, CometChatError.localized(e), CometChatSnackBar.ERROR);
}
});
}
use of com.cometchat.pro.exceptions.CometChatException 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);
}
});
}
use of com.cometchat.pro.exceptions.CometChatException in project android-java-chat-push-notification-app by cometchat-pro.
the class CallUtils method initiateCall.
/**
* This method is used to initiate a call for user or a group.
* @param context is a object of Context
* @param recieverID is String - It can be either uid or guid
* @param receiverType is String - It can be either user or group
* [<code>CometChatConstants.RECEIVER_TYPE_USER</code> or
* <code>CometChatConstants.RECEIVER_TYPE_GROUP</code>]
* @param callType is String - It can be either audio or video
* [<code>CometChatConstants.CALL_TYPE_AUDIO</code> or
* <code>CometChatConstants.CALL_TYPE_VIDEO</code>]
*
* @see CometChat#initiateCall(Call, CometChat.CallbackListener)
*/
public static void initiateCall(Context context, String recieverID, String receiverType, String callType) {
Call call = new Call(recieverID, receiverType, callType);
CometChat.initiateCall(call, new CometChat.CallbackListener<Call>() {
@Override
public void onSuccess(Call call) {
if (receiverType.equalsIgnoreCase(com.cometchat.pro.constants.CometChatConstants.RECEIVER_TYPE_USER))
startCallIntent(context, ((User) call.getCallReceiver()), call.getType(), true, call.getSessionId());
else if (receiverType.equalsIgnoreCase(com.cometchat.pro.constants.CometChatConstants.RECEIVER_TYPE_GROUP))
startGroupCallIntent(context, ((Group) call.getCallReceiver()), call.getType(), true, call.getSessionId());
}
@Override
public void onError(CometChatException e) {
Log.e(TAG, "onError: " + e.getMessage());
Snackbar.make(((Activity) context).getWindow().getDecorView().getRootView(), context.getResources().getString(R.string.call_initiate_error) + ":" + e.getMessage(), Snackbar.LENGTH_LONG).show();
}
});
}
Aggregations