use of com.applozic.mobicomkit.listners.AttachmentFilteringListener in project Applozic-Android-SDK by AppLozic.
the class MobiComAttachmentSelectorActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
try {
if (imagesAdapter != null) {
View view = galleryImagesGridView.getChildAt(imagesAdapter.getCount() - 1);
if (view != null) {
ImageView imageView = view.findViewById(R.id.galleryImageView);
if (imageView != null) {
imageView.setEnabled(true);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (resultCode == Activity.RESULT_OK) {
final Uri selectedFileUri = (intent == null ? null : intent.getData());
Utils.printLog(MobiComAttachmentSelectorActivity.this, TAG, "selectedFileUri :: " + selectedFileUri);
if (selectedFileUri != null) {
if (getApplicationContext() instanceof AttachmentFilteringListener) {
AttachmentFilteringListener filteringListener = (AttachmentFilteringListener) getApplicationContext();
filteringListener.onAttachmentSelected(this, selectedFileUri, new AlCallback() {
@Override
public void onSuccess(Object response) {
processUri(selectedFileUri);
}
@Override
public void onError(Object error) {
Utils.printLog(getApplicationContext(), TAG, "Error in file : " + GsonUtils.getJsonFromObject(error, Object.class));
}
});
} else {
processUri(selectedFileUri);
}
}
}
super.onActivityResult(requestCode, resultCode, intent);
}
use of com.applozic.mobicomkit.listners.AttachmentFilteringListener in project Applozic-Android-SDK by AppLozic.
the class MobiComKitPeopleActivity method onGroupSelected.
@Override
public void onGroupSelected(final Channel channel) {
Intent intent = null;
if (Intent.ACTION_SEND.equals(action) && type != null) {
if (!ChannelService.getInstance(MobiComKitPeopleActivity.this).processIsUserPresentInChannel(channel.getKey())) {
Toast.makeText(this, getString(R.string.unable_share_message), Toast.LENGTH_SHORT).show();
return;
}
if ("text/plain".equals(type)) {
intent = new Intent(this, ConversationActivity.class);
intent.putExtra(GROUP_ID, channel.getKey());
intent.putExtra(GROUP_NAME, channel.getName());
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);
if (fileUri != null) {
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, null, channel);
}
@Override
public void onError(Object error) {
Utils.printLog(getApplicationContext(), TAG, "Error in file : " + GsonUtils.getJsonFromObject(error, Object.class));
}
});
} else {
processAttachmentUri(fileUri, null, channel);
}
}
}
} else {
intent = new Intent();
intent.putExtra(GROUP_ID, channel.getKey());
intent.putExtra(GROUP_NAME, channel.getName());
finishActivity(intent);
}
}
use of com.applozic.mobicomkit.listners.AttachmentFilteringListener 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