use of com.xabber.android.data.database.messagerealm.Attachment in project xabber-android by redsolution.
the class HttpFileUploadManager method parseFileMessage.
public static RealmList<Attachment> parseFileMessage(Stanza packet) {
RealmList<Attachment> attachments = new RealmList<>();
// parsing data references
List<RefMedia> refMediaList = ReferencesManager.getMediaFromReferences(packet);
if (!refMediaList.isEmpty()) {
for (RefMedia media : refMediaList) {
attachments.add(refMediaToAttachment(media));
}
}
// parsing data forms
DataForm dataForm = DataForm.from(packet);
if (dataForm != null) {
List<FormField> fields = dataForm.getFields();
for (FormField field : fields) {
if (field instanceof ExtendedFormField) {
ExtendedFormField.Media media = ((ExtendedFormField) field).getMedia();
attachments.add(mediaToAttachment(media, field.getLabel()));
}
}
}
return attachments;
}
use of com.xabber.android.data.database.messagerealm.Attachment in project xabber-android by redsolution.
the class ImageViewerActivity method onCopyLinkClick.
private void onCopyLinkClick() {
int position = viewPager.getCurrentItem();
Attachment attachment = imageAttachments.get(position);
String url = attachment.getFileUrl();
ClipboardManager clipboardManager = ((ClipboardManager) this.getSystemService(Context.CLIPBOARD_SERVICE));
if (clipboardManager != null)
clipboardManager.setPrimaryClip(ClipData.newPlainText(url, url));
Toast.makeText(this, R.string.toast_link_copied, Toast.LENGTH_SHORT).show();
}
use of com.xabber.android.data.database.messagerealm.Attachment in project xabber-android by redsolution.
the class ImageViewerActivity method setUpMenuOptions.
private void setUpMenuOptions(Menu menu) {
int position = viewPager.getCurrentItem();
Attachment attachment = imageAttachments.get(position);
String filePath = attachment.getFilePath();
Long size = attachment.getFileSize();
menu.findItem(R.id.action_download_image).setVisible(filePath == null && size != null);
menu.findItem(R.id.action_download_image).setEnabled(!isDownloading);
menu.findItem(R.id.action_done).setVisible(filePath != null);
menu.findItem(R.id.action_share).setVisible(size != null);
}
use of com.xabber.android.data.database.messagerealm.Attachment in project xabber-android by redsolution.
the class ImageViewerActivity method subscribeForAttachment.
private void subscribeForAttachment(Attachment attachment) {
if (attachment == null)
return;
Realm realm = MessageDatabaseManager.getInstance().getRealmUiThread();
Attachment attachmentForSubscribe = realm.where(Attachment.class).equalTo(Attachment.Fields.UNIQUE_ID, attachment.getUniqueId()).findFirst();
if (attachmentForSubscribe == null)
return;
Observable<Attachment> observable = attachmentForSubscribe.asObservable();
attachmentStateSubscription.add(observable.doOnNext(new Action1<Attachment>() {
@Override
public void call(Attachment attachment) {
updateToolbar();
if (waitForSharing) {
waitForSharing = false;
onShareClick();
}
}
}).subscribe());
}
use of com.xabber.android.data.database.messagerealm.Attachment in project xabber-android by redsolution.
the class ImageViewerActivity method downloadImage.
private void downloadImage() {
int position = viewPager.getCurrentItem();
Attachment attachment = imageAttachments.get(position);
DownloadManager.getInstance().downloadFile(attachment, accountJid, this);
}
Aggregations