mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Convert AttachmentTable and models to kotlin.
This commit is contained in:
committed by
Alex Hart
parent
888a40a5c4
commit
3554f82ea3
@@ -344,7 +344,7 @@ public class MessageSender {
|
||||
List<AttachmentId> attachmentIds = new ArrayList<>(preUploadAttachmentIds.size());
|
||||
|
||||
for (int i = 0; i < preUploadAttachments.size(); i++) {
|
||||
AttachmentId attachmentId = attachmentDatabase.insertAttachmentForPreUpload(preUploadAttachments.get(i)).getAttachmentId();
|
||||
AttachmentId attachmentId = attachmentDatabase.insertAttachmentForPreUpload(preUploadAttachments.get(i)).attachmentId;
|
||||
attachmentCopies.get(i).add(attachmentId);
|
||||
attachmentIds.add(attachmentId);
|
||||
}
|
||||
@@ -418,14 +418,14 @@ public class MessageSender {
|
||||
DatabaseAttachment databaseAttachment = attachmentDatabase.insertAttachmentForPreUpload(attachment);
|
||||
|
||||
Job compressionJob = AttachmentCompressionJob.fromAttachment(databaseAttachment, false, -1);
|
||||
Job uploadJob = new AttachmentUploadJob(databaseAttachment.getAttachmentId());
|
||||
Job uploadJob = new AttachmentUploadJob(databaseAttachment.attachmentId);
|
||||
|
||||
ApplicationDependencies.getJobManager()
|
||||
.startChain(compressionJob)
|
||||
.then(uploadJob)
|
||||
.enqueue();
|
||||
|
||||
return new PreUploadResult(media, databaseAttachment.getAttachmentId(), Arrays.asList(compressionJob.getId(), uploadJob.getId()));
|
||||
return new PreUploadResult(media, databaseAttachment.attachmentId, Arrays.asList(compressionJob.getId(), uploadJob.getId()));
|
||||
} catch (MmsException e) {
|
||||
Log.w(TAG, "preUploadPushAttachment() - Failed to upload!", e);
|
||||
return null;
|
||||
@@ -645,7 +645,7 @@ public class MessageSender {
|
||||
.toList();
|
||||
|
||||
List<AttachmentMarkUploadedJob> fakeUploadJobs = Stream.of(attachments)
|
||||
.map(a -> new AttachmentMarkUploadedJob(messageId, ((DatabaseAttachment) a).getAttachmentId()))
|
||||
.map(a -> new AttachmentMarkUploadedJob(messageId, ((DatabaseAttachment) a).attachmentId))
|
||||
.toList();
|
||||
|
||||
ApplicationDependencies.getJobManager().startChain(compressionJobs)
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.thoughtcrime.securesms.attachments.AttachmentId
|
||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment
|
||||
import org.thoughtcrime.securesms.attachments.UriAttachment
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable.TransformProperties
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager
|
||||
import org.thoughtcrime.securesms.jobs.AttachmentCompressionJob
|
||||
@@ -43,7 +44,7 @@ class UploadDependencyGraph private constructor(
|
||||
*/
|
||||
private data class AttachmentKey<A : Attachment>(
|
||||
val attachment: A,
|
||||
private val transformProperties: AttachmentTable.TransformProperties = attachment.transformProperties
|
||||
private val transformProperties: AttachmentTable.TransformProperties = attachment.transformProperties ?: AttachmentTable.TransformProperties.empty()
|
||||
)
|
||||
|
||||
private var hasConsumedJobQueue = false
|
||||
@@ -75,14 +76,14 @@ class UploadDependencyGraph private constructor(
|
||||
* Allows representation of a unique database attachment by its internal id and its transform properties.
|
||||
*/
|
||||
private fun DatabaseAttachment.asDatabaseAttachmentKey(): AttachmentKey<DatabaseAttachment> {
|
||||
return AttachmentKey(this, this.transformProperties)
|
||||
return AttachmentKey(this, this.transformProperties ?: TransformProperties.empty())
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows representation of a unique URI attachment by its internal Uri and its transform properties.
|
||||
*/
|
||||
private fun UriAttachment.asUriAttachmentKey(): AttachmentKey<UriAttachment> {
|
||||
return AttachmentKey(this, transformProperties)
|
||||
return AttachmentKey(this, transformProperties ?: TransformProperties.empty())
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +120,7 @@ class UploadDependencyGraph private constructor(
|
||||
message.linkPreviews.mapNotNull { it.thumbnail.orElse(null) } +
|
||||
message.sharedContacts.mapNotNull { it.avatar?.attachment }
|
||||
|
||||
val uniqueAttachments: Set<AttachmentKey<Attachment>> = attachmentList.map { AttachmentKey(it, it.transformProperties) }.toSet()
|
||||
val uniqueAttachments: Set<AttachmentKey<Attachment>> = attachmentList.map { AttachmentKey(it, it.transformProperties ?: TransformProperties.empty()) }.toSet()
|
||||
|
||||
for (attachmentKey in uniqueAttachments) {
|
||||
when (val attachment = attachmentKey.attachment) {
|
||||
|
||||
Reference in New Issue
Block a user