use of com.cometchat.pro.exceptions.CometChatException in project android-java-chat-push-notification-app by cometchat-pro.
the class LoginActivity method registerPushNotification.
private void registerPushNotification(String token) {
CometChat.registerTokenForPushNotification(token, new CometChat.CallbackListener<String>() {
@Override
public void onSuccess(String s) {
Toast.makeText(LoginActivity.this, s, Toast.LENGTH_LONG).show();
Log.e("onSuccessPN: ", s);
}
@Override
public void onError(CometChatException e) {
Log.e("onErrorPN: ", e.getMessage());
Toast.makeText(LoginActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
progressBar.setVisibility(View.GONE);
finish();
startActivity(new Intent(LoginActivity.this, PushNotificationActivity.class));
}
use of com.cometchat.pro.exceptions.CometChatException in project android-java-chat-push-notification-app by cometchat-pro.
the class MainActivity method registerPushNotification.
private void registerPushNotification(String uid, String token) {
Log.e(TAG, "onComplete: " + token);
CometChat.registerTokenForPushNotification(token, new CometChat.CallbackListener<String>() {
@Override
public void onSuccess(String s) {
Toast.makeText(MainActivity.this, s, Toast.LENGTH_LONG).show();
Log.e("onSuccessPN: ", s);
}
@Override
public void onError(CometChatException e) {
Log.e("onErrorPN: ", e.getMessage());
Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
String str = uid + "_progressbar";
int id = getResources().getIdentifier(str, "id", getPackageName());
findViewById(id).setVisibility(View.GONE);
startActivity(new Intent(MainActivity.this, PushNotificationActivity.class));
}
use of com.cometchat.pro.exceptions.CometChatException in project android-java-chat-push-notification-app by cometchat-pro.
the class MoreActionFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_more_actions, container, false);
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
BottomSheetDialog dialog = (BottomSheetDialog) getDialog();
// androidx should use: com.google.android.material.R.id.design_bottom_sheet
FrameLayout bottomSheet = (FrameLayout) dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet);
BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
behavior.setPeekHeight(0);
}
});
loggedInUser = view.findViewById(R.id.loggedIn_user);
loggedInUser.setText("Logged In As : " + CometChat.getLoggedInUser().getName());
logout = view.findViewById(R.id.logout_tv);
logout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// MyFirebaseMessagingService.unsubscribeUserNotification(CometChat.getLoggedInUser().getUid());
CometChat.logout(new CometChat.CallbackListener<String>() {
@Override
public void onSuccess(String s) {
if (getActivity() != null) {
getActivity().finish();
Toast.makeText(getActivity(), getResources().getString(R.string.logout_success), Toast.LENGTH_LONG).show();
}
}
@Override
public void onError(CometChatException e) {
Log.e(TAG, "onError: " + e.getMessage());
}
});
}
});
launchUI = view.findViewById(R.id.launch_ui_kit);
launchUI.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getContext(), CometChatUI.class));
}
});
return view;
}
use of com.cometchat.pro.exceptions.CometChatException in project android-java-chat-push-notification-app by cometchat-pro.
the class CometChatStartCallActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activity = this;
setContentView(R.layout.activity_cometchat_start_call);
ongoingCallService = new OngoingCallService();
mServiceIntent = new Intent(this, ongoingCallService.getClass());
isDefaultCall = getIntent().getBooleanExtra(UIKitConstants.IntentStrings.IS_DEFAULT_CALL, false);
if (isDefaultCall && !isMyServiceRunning(ongoingCallService.getClass())) {
startService(mServiceIntent);
}
mainView = findViewById(R.id.call_view);
connectingLayout = findViewById(R.id.connecting_to_call);
sessionID = getIntent().getStringExtra(UIKitConstants.IntentStrings.SESSION_ID);
type = getIntent().getStringExtra(UIKitConstants.IntentStrings.TYPE);
if (type != null && type.equalsIgnoreCase(CometChatConstants.RECEIVER_TYPE_USER))
callSettings = new CallSettings.CallSettingsBuilder(this, mainView).setSessionId(sessionID).setMode(CallSettings.MODE_SINGLE).build();
else
callSettings = new CallSettings.CallSettingsBuilder(this, mainView).setSessionId(sessionID).build();
CometChatError.init(this);
Log.e("startCallActivity: ", sessionID + " " + type);
CometChat.startCall(callSettings, new CometChat.OngoingCallListener() {
@Override
public void onUserListUpdated(List<User> list) {
Log.e("onUserListUpdated: ", list.toString());
}
@Override
public void onAudioModesUpdated(List<AudioMode> list) {
Log.e("onAudioModesUpdated: ", list.toString());
}
@Override
public void onUserJoined(User user) {
connectingLayout.setVisibility(View.GONE);
CometChatSnackBar.show(CometChatStartCallActivity.this, mainView, getString(R.string.user_joined) + ":" + user.getName(), CometChatSnackBar.INFO);
Log.e("onUserJoined: ", user.getUid());
}
@Override
public void onUserLeft(User user) {
if (user != null) {
CometChatSnackBar.show(CometChatStartCallActivity.this, mainView, getString(R.string.user_left) + ":" + user.getName(), CometChatSnackBar.INFO);
Log.e("onUserLeft: ", user.getUid());
if (callSettings.getMode().equals(CallSettings.MODE_SINGLE)) {
endCall();
}
} else {
Log.e("onUserLeft: ", "triggered");
}
}
@Override
public void onError(CometChatException e) {
stopService(mServiceIntent);
Log.e("onstartcallError: ", e.getMessage());
CometChatSnackBar.show(CometChatStartCallActivity.this, mainView, CometChatError.localized(e), CometChatSnackBar.ERROR);
}
@Override
public void onCallEnded(Call call) {
stopService(mServiceIntent);
Log.e("TAG", "onCallEnded: ");
finish();
}
});
}
use of com.cometchat.pro.exceptions.CometChatException in project android-java-chat-push-notification-app by cometchat-pro.
the class CometChatUserDetailScreenActivity method blockUser.
private void blockUser() {
ProgressDialog progressDialog = ProgressDialog.show(CometChatUserDetailScreenActivity.this, null, String.format(getResources().getString(R.string.user_is_blocked), userName.getText().toString()));
ArrayList<String> uids = new ArrayList<>();
uids.add(uid);
CometChat.blockUsers(uids, new CometChat.CallbackListener<HashMap<String, String>>() {
@Override
public void onSuccess(HashMap<String, String> stringStringHashMap) {
// if (tvBlockUser!=null)
// CometChatSnackBar.show(CometChatUserDetailScreenActivity.this,
// tvBlockUser,
// String.format(getResources().getString(R.string.user_is_blocked),userName.getText().toString()),
// CometChatSnackBar.SUCCESS);
isBlocked = true;
progressDialog.dismiss();
setBlockUnblock();
}
@Override
public void onError(CometChatException e) {
if (tvBlockUser != null)
CometChatSnackBar.show(CometChatUserDetailScreenActivity.this, tvBlockUser, String.format(getResources().getString(R.string.block_user_error), userName.getText().toString()), CometChatSnackBar.ERROR);
Log.d(TAG, "onError: " + e.getMessage());
}
});
}
Aggregations