Java Code Examples for com.evernote.android.job.JobRequest#isTransient()
The following examples show how to use
com.evernote.android.job.JobRequest#isTransient() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobProxyWorkManager.java From android-job with Apache License 2.0 | 6 votes |
@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(), TimeUnit.MILLISECONDS) // don't use the average here, WorkManager will do the right thing .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); }
Example 2
Source File: JobProxy21.java From android-job with Apache License 2.0 | 5 votes |
@SuppressWarnings("SimplifiableIfStatement") protected boolean isJobInfoScheduled(@Nullable JobInfo info, @NonNull JobRequest request) { boolean correctInfo = info != null && info.getId() == request.getJobId(); if (!correctInfo) { return false; } return !request.isTransient() || TransientBundleCompat.isScheduled(mContext, request.getJobId()); }
Example 3
Source File: JobProxy21.java From android-job with Apache License 2.0 | 5 votes |
protected JobInfo.Builder setTransientBundle(JobRequest request, JobInfo.Builder builder) { if (request.isTransient()) { TransientBundleCompat.persistBundle(mContext, request); } return builder; }
Example 4
Source File: PlatformWorker.java From android-job with Apache License 2.0 | 5 votes |
@NonNull @Override public Result doWork() { final int jobId = getJobId(); if (jobId < 0) { return Result.failure(); } try { JobProxy.Common common = new JobProxy.Common(getApplicationContext(), CAT, jobId); JobRequest request = common.getPendingRequest(true, true); if (request == null) { return Result.failure(); } Bundle transientBundle = null; if (request.isTransient()) { transientBundle = TransientBundleHolder.getBundle(jobId); if (transientBundle == null) { CAT.d("Transient bundle is gone for request %s", request); return Result.failure(); } } Job.Result result = common.executeJobRequest(request, transientBundle); if (Job.Result.SUCCESS == result) { return Result.success(); } else { return Result.failure(); } } finally { TransientBundleHolder.cleanUpBundle(jobId); } }