use of org.thoughtcrime.securesms.sms.MessageSender.PreUploadResult in project Signal-Android by signalapp.
the class MediaUploadRepository method uploadMediaInternal.
@WorkerThread
private void uploadMediaInternal(@NonNull Media media, @Nullable Recipient recipient) {
Attachment attachment = asAttachment(context, media);
PreUploadResult result = MessageSender.preUploadPushAttachment(context, attachment, recipient);
if (result != null) {
uploadResults.put(media, result);
} else {
Log.w(TAG, "Failed to upload media with URI: " + media.getUri());
}
}
use of org.thoughtcrime.securesms.sms.MessageSender.PreUploadResult in project Signal-Android by signalapp.
the class MediaUploadRepository method updateDisplayOrderInternal.
@WorkerThread
private void updateDisplayOrderInternal(@NonNull List<Media> mediaInOrder) {
Map<AttachmentId, Integer> orderMap = new HashMap<>();
Map<Media, PreUploadResult> orderedUploadResults = new LinkedHashMap<>();
for (int i = 0; i < mediaInOrder.size(); i++) {
Media media = mediaInOrder.get(i);
PreUploadResult result = uploadResults.get(media);
if (result != null) {
orderMap.put(result.getAttachmentId(), i);
orderedUploadResults.put(media, result);
} else {
Log.w(TAG, "When updating display order, no pre-upload result could be found for media with URI: " + media.getUri());
}
}
SignalDatabase.attachments().updateDisplayOrder(orderMap);
if (orderedUploadResults.size() == uploadResults.size()) {
uploadResults.clear();
uploadResults.putAll(orderedUploadResults);
}
}
use of org.thoughtcrime.securesms.sms.MessageSender.PreUploadResult in project Signal-Android by WhisperSystems.
the class MediaUploadRepository method updateDisplayOrderInternal.
@WorkerThread
private void updateDisplayOrderInternal(@NonNull List<Media> mediaInOrder) {
Map<AttachmentId, Integer> orderMap = new HashMap<>();
Map<Media, PreUploadResult> orderedUploadResults = new LinkedHashMap<>();
for (int i = 0; i < mediaInOrder.size(); i++) {
Media media = mediaInOrder.get(i);
PreUploadResult result = uploadResults.get(media);
if (result != null) {
orderMap.put(result.getAttachmentId(), i);
orderedUploadResults.put(media, result);
} else {
Log.w(TAG, "When updating display order, no pre-upload result could be found for media with URI: " + media.getUri());
}
}
SignalDatabase.attachments().updateDisplayOrder(orderMap);
if (orderedUploadResults.size() == uploadResults.size()) {
uploadResults.clear();
uploadResults.putAll(orderedUploadResults);
}
}
use of org.thoughtcrime.securesms.sms.MessageSender.PreUploadResult in project Signal-Android by WhisperSystems.
the class MediaUploadRepository method cancelUploadInternal.
private void cancelUploadInternal(@NonNull Media media) {
JobManager jobManager = ApplicationDependencies.getJobManager();
PreUploadResult result = uploadResults.get(media);
if (result != null) {
Stream.of(result.getJobIds()).forEach(jobManager::cancel);
uploadResults.remove(media);
}
}
use of org.thoughtcrime.securesms.sms.MessageSender.PreUploadResult in project Signal-Android by WhisperSystems.
the class MediaUploadRepository method uploadMediaInternal.
@WorkerThread
private void uploadMediaInternal(@NonNull Media media, @Nullable Recipient recipient) {
Attachment attachment = asAttachment(context, media);
PreUploadResult result = MessageSender.preUploadPushAttachment(context, attachment, recipient);
if (result != null) {
uploadResults.put(media, result);
} else {
Log.w(TAG, "Failed to upload media with URI: " + media.getUri());
}
}
Aggregations