use of com.evernote.android.job.util.support.PersistableBundleCompat in project android-job by evernote.
the class MainActivity method testSimple.
private void testSimple() {
PersistableBundleCompat extras = new PersistableBundleCompat();
extras.putString("key", "Hello world");
mLastJobId = new JobRequest.Builder(DemoSyncJob.TAG).setExecutionWindow(3_000L, 4_000L).setBackoffCriteria(5_000L, JobRequest.BackoffPolicy.LINEAR).setRequiresCharging(mRequiresCharging.isChecked()).setRequiresDeviceIdle(mRequiresDeviceIdle.isChecked()).setRequiredNetworkType(JobRequest.NetworkType.values()[mNetworkTypeSpinner.getSelectedItemPosition()]).setExtras(extras).setRequirementsEnforced(true).setPersisted(true).build().schedule();
}
use of com.evernote.android.job.util.support.PersistableBundleCompat in project android-job by evernote.
the class MainActivity method testExact.
private void testExact() {
PersistableBundleCompat extras = new PersistableBundleCompat();
extras.putString("key", "Hello world");
mLastJobId = new JobRequest.Builder(DemoSyncJob.TAG).setBackoffCriteria(5_000L, JobRequest.BackoffPolicy.EXPONENTIAL).setExtras(extras).setExact(20_000L).setPersisted(true).setUpdateCurrent(true).build().schedule();
}
use of com.evernote.android.job.util.support.PersistableBundleCompat in project cw-omnibus by commonsguy.
the class MainActivity method manageUnified.
private void manageUnified(boolean start) {
if (start) {
final JobRequest.Builder b = new JobRequest.Builder(DemoUnifiedJob.JOB_TAG);
PersistableBundleCompat extras = new PersistableBundleCompat();
if (download.isChecked()) {
extras.putBoolean(KEY_DOWNLOAD, true);
b.setExtras(extras).setRequiredNetworkType(JobRequest.NetworkType.CONNECTED);
} else {
b.setRequiredNetworkType(JobRequest.NetworkType.ANY);
}
b.setPeriodic(getPeriod()).setPersisted(false).setRequiresCharging(false).setRequiresDeviceIdle(true);
unifiedJobId = b.build().schedule();
} else {
JobManager.instance().cancel(unifiedJobId);
}
}
use of com.evernote.android.job.util.support.PersistableBundleCompat in project android-job by evernote.
the class JobRequestTest method testSimpleJob.
@Test
public void testSimpleJob() {
JobRequest request = getBuilder().setExecutionWindow(2_000L, 3_000L).setBackoffCriteria(4_000, JobRequest.BackoffPolicy.LINEAR).setExtras(new PersistableBundleCompat()).setPersisted(true).build();
assertThat(request.getJobId()).isGreaterThan(0);
assertThat(request.getTag()).isEqualTo(TestJob.TAG);
assertThat(request.getStartMs()).isEqualTo(2_000L);
assertThat(request.getEndMs()).isEqualTo(3_000L);
assertThat(request.getBackoffMs()).isEqualTo(4_000L);
assertThat(request.getBackoffPolicy()).isEqualTo(JobRequest.BackoffPolicy.LINEAR);
assertThat(request.isPersisted()).isTrue();
assertThat(request.getExtras()).isNotNull();
assertThat(request.getIntervalMs()).isZero();
assertThat(request.isExact()).isFalse();
assertThat(request.isPeriodic()).isFalse();
assertThat(request.requiredNetworkType()).isEqualTo(JobRequest.DEFAULT_NETWORK_TYPE);
assertThat(request.requirementsEnforced()).isFalse();
assertThat(request.requiresCharging()).isFalse();
assertThat(request.requiresDeviceIdle()).isFalse();
}
use of com.evernote.android.job.util.support.PersistableBundleCompat in project android-job by evernote.
the class JobRequestTest method testPeriodic.
@Test
public void testPeriodic() {
long interval = JobRequest.MIN_INTERVAL * 5;
JobRequest request = getBuilder().setPeriodic(interval).setExtras(new PersistableBundleCompat()).setPersisted(true).build();
assertThat(request.getJobId()).isGreaterThan(0);
assertThat(request.getTag()).isEqualTo(TestJob.TAG);
assertThat(request.isPersisted()).isTrue();
assertThat(request.getIntervalMs()).isEqualTo(interval);
assertThat(request.getFlexMs()).isEqualTo(interval);
assertThat(request.isPeriodic()).isTrue();
assertThat(request.isFlexSupport()).isFalse();
assertThat(request.getStartMs()).isNegative();
assertThat(request.getEndMs()).isNegative();
assertThat(request.getBackoffMs()).isEqualTo(JobRequest.DEFAULT_BACKOFF_MS);
assertThat(request.getBackoffPolicy()).isEqualTo(JobRequest.DEFAULT_BACKOFF_POLICY);
assertThat(request.getExtras()).isNotNull();
assertThat(request.isExact()).isFalse();
assertThat(request.requiredNetworkType()).isEqualTo(JobRequest.DEFAULT_NETWORK_TYPE);
assertThat(request.requirementsEnforced()).isFalse();
assertThat(request.requiresCharging()).isFalse();
assertThat(request.requiresDeviceIdle()).isFalse();
}
Aggregations