use of com.cometchat.pro.exceptions.CometChatException 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.exceptions.CometChatException in project android-java-chat-push-notification-app by cometchat-pro.
the class UIKitApplication method onCreate.
@Override
public void onCreate() {
super.onCreate();
AppSettings appSettings = new AppSettings.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(AppConfig.AppDetails.REGION).build();
CometChat.init(this, AppConfig.AppDetails.APP_ID, appSettings, new CometChat.CallbackListener<String>() {
@Override
public void onSuccess(String s) {
CometChat.setSource("push-notification", "android", "java");
Log.d(TAG, "onSuccess: " + s);
}
@Override
public void onError(CometChatException e) {
Toast.makeText(UIKitApplication.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
CometChatCallListener.addCallListener(TAG, this);
createNotificationChannel();
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
}
use of com.cometchat.pro.exceptions.CometChatException in project android-java-chat-push-notification-app by cometchat-pro.
the class CallNotificationAction method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
String sessionID = intent.getStringExtra(UIKitConstants.IntentStrings.SESSION_ID);
Log.e(TAG, "onReceive: " + intent.getStringExtra(UIKitConstants.IntentStrings.SESSION_ID));
if (intent.getAction().equals("Answers")) {
CometChat.acceptCall(sessionID, new CometChat.CallbackListener<Call>() {
@Override
public void onSuccess(Call call) {
Intent acceptIntent = new Intent(context, CometChatStartCallActivity.class);
acceptIntent.putExtra(UIKitConstants.IntentStrings.SESSION_ID, call.getSessionId());
acceptIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(acceptIntent);
}
@Override
public void onError(CometChatException e) {
Toast.makeText(context, "Error " + e.getMessage(), Toast.LENGTH_LONG).show();
}
});
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.cancel(05);
} else if (intent.getAction().equals("Decline")) {
CometChat.rejectCall(sessionID, CometChatConstants.CALL_STATUS_REJECTED, new CometChat.CallbackListener<Call>() {
@Override
public void onSuccess(Call call) {
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.cancel(05);
if (CometChatCallActivity.callActivity != null)
CometChatCallActivity.callActivity.finish();
}
@Override
public void onError(CometChatException e) {
Toast.makeText(context, "Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
});
}
}
use of com.cometchat.pro.exceptions.CometChatException in project android-java-chat-push-notification-app by cometchat-pro.
the class CreateUserActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_user);
inputUid = findViewById(R.id.inputUID);
inputName = findViewById(R.id.inputName);
title = findViewById(R.id.tvTitle);
des1 = findViewById(R.id.tvDes1);
des2 = findViewById(R.id.tvDes2);
progressBar = findViewById(R.id.createUser_pb);
uid = findViewById(R.id.etUID);
name = findViewById(R.id.etName);
createUserBtn = findViewById(R.id.create_user_btn);
createUserBtn.setTextColor(getResources().getColor(R.color.textColorWhite));
createUserBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (uid.getText().toString().isEmpty())
uid.setError(getResources().getString(R.string.fill_this_field));
else if (name.getText().toString().isEmpty())
name.setError(getResources().getString(R.string.fill_this_field));
else {
progressBar.setVisibility(View.VISIBLE);
createUserBtn.setClickable(false);
User user = new User();
user.setUid(uid.getText().toString());
user.setName(name.getText().toString());
CometChat.createUser(user, AppConfig.AppDetails.AUTH_KEY, new CometChat.CallbackListener<User>() {
@Override
public void onSuccess(User user) {
login(user);
}
@Override
public void onError(CometChatException e) {
createUserBtn.setClickable(true);
Toast.makeText(CreateUserActivity.this, "Failed to create user", Toast.LENGTH_LONG).show();
}
});
}
}
});
checkDarkMode();
}
use of com.cometchat.pro.exceptions.CometChatException in project android-java-chat-push-notification-app by cometchat-pro.
the class CometChatBlockUserList method unBlockUser.
private void unBlockUser(User user, View var1) {
ProgressDialog progressDialog = ProgressDialog.show(getContext(), null, user.getName() + " " + getResources().getString(R.string.unblocked_successfully));
ArrayList<String> uids = new ArrayList<>();
uids.add(user.getUid());
CometChat.unblockUsers(uids, new CometChat.CallbackListener<HashMap<String, String>>() {
@Override
public void onSuccess(HashMap<String, String> stringStringHashMap) {
if (userList.contains(user))
userList.remove(user);
blockedUserAdapter.removeUser(user);
progressDialog.dismiss();
// CometChatSnackBar.show(getContext(),var1,
// ,CometChatSnackBar.SUCCESS);
checkIfNoUserVisible();
}
@Override
public void onError(CometChatException e) {
progressDialog.dismiss();
CometChatSnackBar.show(getContext(), var1, CometChatError.localized(e), CometChatSnackBar.ERROR);
Log.e(TAG, "onError: " + e.getMessage());
}
});
}
Aggregations