use of com.cometchat.pro.core.CallSettings 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();
}
});
}
Aggregations