Search in sources :

Example 1 with JobProxyIllegalStateException

use of com.evernote.android.job.JobProxyIllegalStateException in project android-job by evernote.

the class JobProxyWorkManager method plantPeriodic.

@Override
public void plantPeriodic(JobRequest request) {
    PeriodicWorkRequest workRequest = new PeriodicWorkRequest.Builder(PlatformWorker.class, request.getIntervalMs(), TimeUnit.MILLISECONDS, request.getFlexMs(), TimeUnit.MILLISECONDS).setConstraints(buildConstraints(request)).addTag(createTag(request.getJobId())).build();
    WorkManager workManager = getWorkManager();
    if (workManager == null) {
        throw new JobProxyIllegalStateException("WorkManager is null");
    }
    workManager.enqueue(workRequest);
}
Also used : WorkManager(androidx.work.WorkManager) JobProxyIllegalStateException(com.evernote.android.job.JobProxyIllegalStateException) PeriodicWorkRequest(androidx.work.PeriodicWorkRequest)

Example 2 with JobProxyIllegalStateException

use of com.evernote.android.job.JobProxyIllegalStateException in project android-job by evernote.

the class JobProxyWorkManager method plantOneOff.

@Override
public void plantOneOff(JobRequest request) {
    if (request.isTransient()) {
        TransientBundleHolder.putBundle(request.getJobId(), request.getTransientExtras());
    }
    OneTimeWorkRequest workRequest = new OneTimeWorkRequest.Builder(PlatformWorker.class).setInitialDelay(request.getStartMs(), // don't use the average here, WorkManager will do the right thing
    TimeUnit.MILLISECONDS).setConstraints(buildConstraints(request)).addTag(createTag(request.getJobId())).build();
    // don't set the back-off criteria, android-job is handling this
    WorkManager workManager = getWorkManager();
    if (workManager == null) {
        throw new JobProxyIllegalStateException("WorkManager is null");
    }
    workManager.enqueue(workRequest);
}
Also used : WorkManager(androidx.work.WorkManager) JobProxyIllegalStateException(com.evernote.android.job.JobProxyIllegalStateException) OneTimeWorkRequest(androidx.work.OneTimeWorkRequest)

Aggregations

WorkManager (androidx.work.WorkManager)2 JobProxyIllegalStateException (com.evernote.android.job.JobProxyIllegalStateException)2 OneTimeWorkRequest (androidx.work.OneTimeWorkRequest)1 PeriodicWorkRequest (androidx.work.PeriodicWorkRequest)1