Search in sources :

Example 46 with JobManager

use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by signalapp.

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);
    }
}
Also used : JobManager(org.thoughtcrime.securesms.jobmanager.JobManager) PreUploadResult(org.thoughtcrime.securesms.sms.MessageSender.PreUploadResult)

Example 47 with JobManager

use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by signalapp.

the class StickerManagementRepository method fetchUnretrievedReferencePacks.

void fetchUnretrievedReferencePacks() {
    SignalExecutors.SERIAL.execute(() -> {
        JobManager jobManager = ApplicationDependencies.getJobManager();
        try (Cursor cursor = attachmentDatabase.getUnavailableStickerPacks()) {
            while (cursor != null && cursor.moveToNext()) {
                String packId = cursor.getString(cursor.getColumnIndexOrThrow(AttachmentDatabase.STICKER_PACK_ID));
                String packKey = cursor.getString(cursor.getColumnIndexOrThrow(AttachmentDatabase.STICKER_PACK_KEY));
                jobManager.add(StickerPackDownloadJob.forReference(packId, packKey));
            }
        }
    });
}
Also used : JobManager(org.thoughtcrime.securesms.jobmanager.JobManager) Cursor(android.database.Cursor)

Example 48 with JobManager

use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by signalapp.

the class StickerManagementRepository method installStickerPack.

void installStickerPack(@NonNull String packId, @NonNull String packKey, boolean notify) {
    SignalExecutors.SERIAL.execute(() -> {
        JobManager jobManager = ApplicationDependencies.getJobManager();
        if (stickerDatabase.isPackAvailableAsReference(packId)) {
            stickerDatabase.markPackAsInstalled(packId, notify);
        }
        jobManager.add(StickerPackDownloadJob.forInstall(packId, packKey, notify));
        if (TextSecurePreferences.isMultiDevice(context)) {
            jobManager.add(new MultiDeviceStickerPackOperationJob(packId, packKey, MultiDeviceStickerPackOperationJob.Type.INSTALL));
        }
    });
}
Also used : MultiDeviceStickerPackOperationJob(org.thoughtcrime.securesms.jobs.MultiDeviceStickerPackOperationJob) JobManager(org.thoughtcrime.securesms.jobmanager.JobManager)

Example 49 with JobManager

use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by signalapp.

the class MessageSender method sendMms.

private static void sendMms(Context context, long messageId) {
    JobManager jobManager = ApplicationDependencies.getJobManager();
    MmsSendJob.enqueue(context, jobManager, messageId);
}
Also used : JobManager(org.thoughtcrime.securesms.jobmanager.JobManager)

Example 50 with JobManager

use of org.thoughtcrime.securesms.jobmanager.JobManager in project Signal-Android by signalapp.

the class StickerLaunchMigrationJob method installPack.

private static void installPack(@NonNull Context context, @NonNull BlessedPacks.Pack pack) {
    JobManager jobManager = ApplicationDependencies.getJobManager();
    StickerDatabase stickerDatabase = SignalDatabase.stickers();
    if (stickerDatabase.isPackAvailableAsReference(pack.getPackId())) {
        stickerDatabase.markPackAsInstalled(pack.getPackId(), false);
    }
    jobManager.add(StickerPackDownloadJob.forInstall(pack.getPackId(), pack.getPackKey(), false));
    if (TextSecurePreferences.isMultiDevice(context)) {
        jobManager.add(new MultiDeviceStickerPackOperationJob(pack.getPackId(), pack.getPackKey(), MultiDeviceStickerPackOperationJob.Type.INSTALL));
    }
}
Also used : MultiDeviceStickerPackOperationJob(org.thoughtcrime.securesms.jobs.MultiDeviceStickerPackOperationJob) StickerDatabase(org.thoughtcrime.securesms.database.StickerDatabase) JobManager(org.thoughtcrime.securesms.jobmanager.JobManager)

Aggregations

JobManager (org.thoughtcrime.securesms.jobmanager.JobManager)58 Job (org.thoughtcrime.securesms.jobmanager.Job)18 IOException (java.io.IOException)14 List (java.util.List)14 NonNull (androidx.annotation.NonNull)10 Log (org.signal.core.util.logging.Log)10 SignalDatabase (org.thoughtcrime.securesms.database.SignalDatabase)10 ApplicationDependencies (org.thoughtcrime.securesms.dependencies.ApplicationDependencies)10 Recipient (org.thoughtcrime.securesms.recipients.Recipient)10 RecipientId (org.thoughtcrime.securesms.recipients.RecipientId)10 WorkerThread (androidx.annotation.WorkerThread)8 TimeUnit (java.util.concurrent.TimeUnit)8 Data (org.thoughtcrime.securesms.jobmanager.Data)8 NetworkConstraint (org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint)8 Application (android.app.Application)6 ArrayList (java.util.ArrayList)6 Collections (java.util.Collections)6 MessageId (org.thoughtcrime.securesms.database.model.MessageId)6 SmsSendJob (org.thoughtcrime.securesms.jobs.SmsSendJob)6 AttachmentCompressionJob (org.thoughtcrime.securesms.jobs.AttachmentCompressionJob)5