use of com.birbit.android.jobqueue.scheduling.SchedulerConstraint in project android-priority-jobqueue by yigit.
the class JobManagerThread method invokeSchedulersIfIdle.
private void invokeSchedulersIfIdle() {
if (scheduler == null || pendingSchedulerCallbacks == null || pendingSchedulerCallbacks.isEmpty() || !consumerManager.areAllConsumersIdle()) {
return;
}
for (int i = pendingSchedulerCallbacks.size() - 1; i >= 0; i--) {
SchedulerConstraint constraint = pendingSchedulerCallbacks.remove(i);
boolean reschedule = hasJobsWithSchedulerConstraint(constraint);
scheduler.onFinished(constraint, reschedule);
}
}
use of com.birbit.android.jobqueue.scheduling.SchedulerConstraint in project android-priority-jobqueue by yigit.
the class BatchingSchedulerTest method createConstraint.
private static SchedulerConstraint createConstraint(int networkStatus, long delay, Long deadline) {
SchedulerConstraint constraint = new SchedulerConstraint("abc");
constraint.setDelayInMs(delay);
constraint.setNetworkStatus(networkStatus);
constraint.setOverrideDeadlineInMs(deadline);
return constraint;
}
use of com.birbit.android.jobqueue.scheduling.SchedulerConstraint in project android-priority-jobqueue by yigit.
the class BatchingSchedulerTest method testAddTwoOfTheSameWithTimeDiff.
@Test
public void testAddTwoOfTheSameWithTimeDiff() {
SchedulerConstraint constraint = createConstraint(NetworkUtil.METERED, 0);
bs.request(constraint);
timer.incrementMs(DEFAULT_BATCHING_PERIOD_IN_MS - 10);
SchedulerConstraint constraint2 = createConstraint(NetworkUtil.METERED, 0);
bs.request(constraint2);
verify(scheduler, times(1)).request(constraint);
verify(scheduler, times(0)).request(constraint2);
MatcherAssert.assertThat(constraint.getDelayInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS));
}
use of com.birbit.android.jobqueue.scheduling.SchedulerConstraint in project android-priority-jobqueue by yigit.
the class BatchingSchedulerTest method testSecondWithDeadline.
@Test
public void testSecondWithDeadline() {
SchedulerConstraint constraint = createConstraint(NetworkUtil.METERED, 0);
bs.request(constraint);
SchedulerConstraint constraint2 = createConstraint(NetworkUtil.METERED, 0, 10L);
bs.request(constraint2);
verify(scheduler, times(1)).request(constraint);
verify(scheduler, times(1)).request(constraint2);
MatcherAssert.assertThat(constraint.getDelayInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS));
MatcherAssert.assertThat(constraint2.getDelayInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS));
MatcherAssert.assertThat(constraint2.getOverrideDeadlineInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS));
}
use of com.birbit.android.jobqueue.scheduling.SchedulerConstraint in project android-priority-jobqueue by yigit.
the class BatchingSchedulerTest method testAddTwoOfTheSame.
@Test
public void testAddTwoOfTheSame() {
SchedulerConstraint constraint = createConstraint(NetworkUtil.METERED, 0);
bs.request(constraint);
SchedulerConstraint constraint2 = createConstraint(NetworkUtil.METERED, 0);
bs.request(constraint2);
verify(scheduler, times(1)).request(constraint);
verify(scheduler, times(0)).request(constraint2);
MatcherAssert.assertThat(constraint.getDelayInMs(), CoreMatchers.is(DEFAULT_BATCHING_PERIOD_IN_MS));
}
Aggregations