use of com.applozic.mobicomkit.api.conversation.AlGroupOfTwoCreateTask in project Applozic-Android-SDK by AppLozic.
the class MobiComKitPeopleActivity method onCustomContactSelected.
@Override
public void onCustomContactSelected(final Contact contact) {
Intent intent = null;
if (Intent.ACTION_SEND.equals(action) && type != null) {
if (contact.isBlocked()) {
Toast.makeText(this, getString(R.string.user_is_blocked), Toast.LENGTH_SHORT).show();
return;
}
if ("text/plain".equals(type)) {
intent = new Intent(this, ConversationActivity.class);
intent.putExtra(USER_ID, contact.getUserId());
intent.putExtra(ConversationUIService.DEFAULT_TEXT, intentExtra.getStringExtra(Intent.EXTRA_TEXT));
startActivity(intent);
finish();
} else if (type.startsWith("image/") || type.startsWith("audio/") || type.startsWith("video/")) {
final Uri fileUri = (Uri) intentExtra.getParcelableExtra(Intent.EXTRA_STREAM);
long maxSize = alCustomizationSettings.getMaxAttachmentSizeAllowed() * 1024 * 1024;
if (FileUtils.isMaxUploadSizeReached(this, fileUri, maxSize)) {
Toast.makeText(this, getString(R.string.info_attachment_max_allowed_file_size), Toast.LENGTH_LONG).show();
return;
}
if (getApplicationContext() instanceof AttachmentFilteringListener) {
((AttachmentFilteringListener) getApplicationContext()).onAttachmentSelected(this, fileUri, new AlCallback() {
@Override
public void onSuccess(Object response) {
processAttachmentUri(fileUri, contact, null);
}
@Override
public void onError(Object error) {
Utils.printLog(getApplicationContext(), TAG, "Error in file : " + GsonUtils.getJsonFromObject(error, Object.class));
}
});
} else {
processAttachmentUri(fileUri, contact, null);
}
}
} else {
if (ApplozicClient.getInstance(this).isStartGroupOfTwo()) {
ProgressDialog progressDialog = ProgressDialog.show(this, "", getString(R.string.please_wait_creating_group_of_two), true);
AlTask.execute(new AlGroupOfTwoCreateTask(MobiComKitPeopleActivity.this, MobiComUserPreference.getInstance(this).getParentGroupKey(), contact, new AlGroupOfTwoCreateTask.ChannelCreateListener() {
@Override
public void onSuccess(@NonNull Channel channel) {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
if (channel != null) {
Intent intent = new Intent(MobiComKitPeopleActivity.this, ConversationActivity.class);
intent.putExtra(ConversationUIService.GROUP_ID, channel.getKey());
intent.putExtra(ConversationUIService.GROUP_NAME, channel.getName());
startActivity(intent);
}
}
@Override
public void onFailure() {
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
}));
} else {
intent = new Intent();
intent.putExtra(USER_ID, contact.getUserId());
finishActivity(intent);
}
}
}
Aggregations