Search in sources :

Example 1 with OneTimeWorkRequest

use of androidx.work.OneTimeWorkRequest in project OneSignal-Android-SDK by OneSignal.

the class OSNotificationRestoreWorkManager method beginEnqueueingWork.

public static void beginEnqueueingWork(Context context, boolean shouldDelay) {
    // When boot or upgrade, add a 15 second delay to alleviate app doing to much work all at once
    int restoreDelayInSeconds = shouldDelay ? 15 : 0;
    OneTimeWorkRequest workRequest = new OneTimeWorkRequest.Builder(NotificationRestoreWorker.class).setInitialDelay(restoreDelayInSeconds, TimeUnit.SECONDS).build();
    WorkManager.getInstance(context).enqueueUniqueWork(NOTIFICATION_RESTORE_WORKER_IDENTIFIER, ExistingWorkPolicy.KEEP, workRequest);
}
Also used : OneTimeWorkRequest(androidx.work.OneTimeWorkRequest)

Example 2 with OneTimeWorkRequest

use of androidx.work.OneTimeWorkRequest in project AntennaPod by AntennaPod.

the class SyncService method sync.

public static void sync(Context context) {
    OneTimeWorkRequest workRequest = getWorkRequest().build();
    WorkManager.getInstance(context).enqueueUniqueWork(WORK_ID_SYNC, ExistingWorkPolicy.REPLACE, workRequest);
}
Also used : OneTimeWorkRequest(androidx.work.OneTimeWorkRequest)

Example 3 with OneTimeWorkRequest

use of androidx.work.OneTimeWorkRequest in project AntennaPod by AntennaPod.

the class AutoUpdateManager method runOnce.

/**
 * Run auto feed refresh once in background, as soon as what OS scheduling allows.
 *
 * Callers from UI should use {@link #runImmediate(Context)}, as it will guarantee
 * the refresh be run immediately.
 * @param context Context
 */
public static void runOnce(Context context) {
    Log.d(TAG, "Run auto update once, as soon as OS allows.");
    OneTimeWorkRequest workRequest = new OneTimeWorkRequest.Builder(FeedUpdateWorker.class).setConstraints(getConstraints()).setInitialDelay(0L, TimeUnit.MILLISECONDS).setInputData(new Data.Builder().putBoolean(FeedUpdateWorker.PARAM_RUN_ONCE, true).build()).build();
    WorkManager.getInstance(context).enqueueUniqueWork(WORK_ID_FEED_UPDATE_ONCE, ExistingWorkPolicy.REPLACE, workRequest);
}
Also used : OneTimeWorkRequest(androidx.work.OneTimeWorkRequest)

Example 4 with OneTimeWorkRequest

use of androidx.work.OneTimeWorkRequest in project ExoPlayer by google.

the class WorkManagerScheduler method schedule.

@Override
public boolean schedule(Requirements requirements, String servicePackage, String serviceAction) {
    Constraints constraints = buildConstraints(requirements);
    Data inputData = buildInputData(requirements, servicePackage, serviceAction);
    OneTimeWorkRequest workRequest = buildWorkRequest(constraints, inputData);
    workManager.enqueueUniqueWork(workName, ExistingWorkPolicy.REPLACE, workRequest);
    return true;
}
Also used : Constraints(androidx.work.Constraints) Data(androidx.work.Data) OneTimeWorkRequest(androidx.work.OneTimeWorkRequest)

Example 5 with OneTimeWorkRequest

use of androidx.work.OneTimeWorkRequest in project AntennaPod by AntennaPod.

the class SyncService method syncImmediately.

public static void syncImmediately(Context context) {
    OneTimeWorkRequest workRequest = getWorkRequest().setInitialDelay(0L, TimeUnit.SECONDS).build();
    WorkManager.getInstance(context).enqueueUniqueWork(WORK_ID_SYNC, ExistingWorkPolicy.REPLACE, workRequest);
}
Also used : OneTimeWorkRequest(androidx.work.OneTimeWorkRequest)

Aggregations

OneTimeWorkRequest (androidx.work.OneTimeWorkRequest)11 Data (androidx.work.Data)3 Constraints (androidx.work.Constraints)2 WorkManager (androidx.work.WorkManager)1 JobProxyIllegalStateException (com.evernote.android.job.JobProxyIllegalStateException)1 FeedUpdateWorker (de.danoeh.antennapod.core.service.FeedUpdateWorker)1 Calendar (java.util.Calendar)1