本文整理了Java中com.firebase.jobdispatcher.Trigger.executionWindow()
方法的一些代码示例,展示了Trigger.executionWindow()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Trigger.executionWindow()
方法的具体详情如下:
包路径:com.firebase.jobdispatcher.Trigger
类名称:Trigger
方法名:executionWindow
[英]Creates a new ExecutionWindow based on the provided time interval.
[中]根据提供的时间间隔创建新的ExecutionWindow。
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@NonNull
private JobTrigger decodeTrigger(Bundle data) {
switch (data.getInt(prefix + BundleProtocol.PACKED_PARAM_TRIGGER_TYPE)) {
case BundleProtocol.TRIGGER_TYPE_IMMEDIATE:
return Trigger.NOW;
case BundleProtocol.TRIGGER_TYPE_EXECUTION_WINDOW:
return Trigger.executionWindow(
data.getInt(prefix + BundleProtocol.PACKED_PARAM_TRIGGER_WINDOW_START),
data.getInt(prefix + BundleProtocol.PACKED_PARAM_TRIGGER_WINDOW_END));
case BundleProtocol.TRIGGER_TYPE_CONTENT_URI:
String uris = data.getString(prefix + BundleProtocol.PACKED_PARAM_OBSERVED_URI);
List<ObservedUri> observedUris = convertJsonToObservedUris(uris);
return Trigger.contentUriTrigger(Collections.unmodifiableList(observedUris));
default:
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Unsupported trigger.");
}
return null;
}
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@Test
public void testNewInstance_withTooSmallWindow_now() throws Exception {
expectedException.expect(IllegalArgumentException.class);
Trigger.executionWindow(60, 59);
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@Test
public void testNewInstance_withNegativeStart() throws Exception {
expectedException.expect(IllegalArgumentException.class);
Trigger.executionWindow(-10, 60);
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@Test
public void testNewInstance_withNegativeEnd() throws Exception {
expectedException.expect(IllegalArgumentException.class);
Trigger.executionWindow(0, -1);
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@Test
public void testNewInstance_withTooSmallWindow_inFuture() throws Exception {
expectedException.expect(IllegalArgumentException.class);
Trigger.executionWindow(200, 100);
}
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@Test
public void testNewInstance_withReversedValues() throws Exception {
expectedException.expect(IllegalArgumentException.class);
Trigger.executionWindow(60, 0);
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@Test
public void testValidate_trigger() throws Exception {
Map<JobTrigger, String> testCases = new HashMap<>();
testCases.put(Trigger.NOW, null);
testCases.put(Trigger.executionWindow(0, 100), null);
ContentUriTrigger contentUriTrigger =
Trigger.contentUriTrigger(
Arrays.asList(
new ObservedUri(
ContactsContract.AUTHORITY_URI, Flags.FLAG_NOTIFY_FOR_DESCENDANTS)));
testCases.put(contentUriTrigger, null);
for (Entry<JobTrigger, String> testCase : testCases.entrySet()) {
List<String> validationErrors = validator.validate(testCase.getKey());
if (testCase.getValue() == null) {
assertNull("Expected no validation errors for trigger", validationErrors);
} else {
assertTrue(
"Expected validation errors to contain \"" + testCase.getValue() + "\"",
validationErrors.contains(testCase.getValue()));
}
}
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@Test
public void testNewInstance_withValidWindow() throws Exception {
JobTrigger.ExecutionWindowTrigger trigger = Trigger.executionWindow(0, 60);
assertEquals(0, trigger.getWindowStart());
assertEquals(60, trigger.getWindowEnd());
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
.setConstraints(Constraint.DEVICE_CHARGING)
.setService(TestJobService.class)
.setTrigger(Trigger.executionWindow(0, 60))
.setRecurring(false)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
代码示例来源:origin: udacity/ud851-Sunshine
.setTrigger(Trigger.executionWindow(
SYNC_INTERVAL_SECONDS,
SYNC_INTERVAL_SECONDS + SYNC_FLEXTIME_SECONDS))
代码示例来源:origin: udacity/ud851-Sunshine
.setTrigger(Trigger.executionWindow(
SYNC_INTERVAL_SECONDS,
SYNC_INTERVAL_SECONDS + SYNC_FLEXTIME_SECONDS))
代码示例来源:origin: udacity/ud851-Sunshine
.setTrigger(Trigger.executionWindow(
SYNC_INTERVAL_SECONDS,
SYNC_INTERVAL_SECONDS + SYNC_FLEXTIME_SECONDS))
代码示例来源:origin: udacity/ud851-Exercises
.setTrigger(Trigger.executionWindow(
REMINDER_INTERVAL_SECONDS,
REMINDER_INTERVAL_SECONDS + SYNC_FLEXTIME_SECONDS))
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@Test
public void testWriteToBundle_triggers() {
// immediate
Bundle b =
writer.writeToBundle(
initializeDefaultBuilder().setTrigger(Trigger.NOW).build(), new Bundle());
assertEquals("window_start", 0, b.getLong("window_start"));
assertEquals("window_end", 1, b.getLong("window_end"));
// execution window (oneoff)
JobTrigger.ExecutionWindowTrigger t = Trigger.executionWindow(631, 978);
b = writer.writeToBundle(initializeDefaultBuilder().setTrigger(t).build(), new Bundle());
assertEquals("window_start", t.getWindowStart(), b.getLong("window_start"));
assertEquals("window_end", t.getWindowEnd(), b.getLong("window_end"));
// execution window (periodic)
b =
writer.writeToBundle(
initializeDefaultBuilder().setRecurring(true).setTrigger(t).build(), new Bundle());
assertEquals("period", t.getWindowEnd(), b.getLong("period"));
assertEquals("period_flex", t.getWindowEnd() - t.getWindowStart(), b.getLong("period_flex"));
}
代码示例来源:origin: udacity/ud851-Sunshine
.setTrigger(Trigger.executionWindow(
SYNC_INTERVAL_SECONDS,
SYNC_INTERVAL_SECONDS + SYNC_FLEXTIME_SECONDS))
代码示例来源:origin: udacity/ud851-Sunshine
.setTrigger(Trigger.executionWindow(
SYNC_INTERVAL_SECONDS,
SYNC_INTERVAL_SECONDS + SYNC_FLEXTIME_SECONDS))
代码示例来源:origin: udacity/ud851-Sunshine
.setTrigger(Trigger.executionWindow(
SYNC_INTERVAL_SECONDS,
SYNC_INTERVAL_SECONDS + SYNC_FLEXTIME_SECONDS))
代码示例来源:origin: udacity/ud851-Sunshine
.setTrigger(Trigger.executionWindow(
SYNC_INTERVAL_SECONDS,
SYNC_INTERVAL_SECONDS + SYNC_FLEXTIME_SECONDS))
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@Test
public void contract_hashCode_equals_triggerShouldBeIgnored() {
JobInvocation jobInvocation = builder.build();
JobInvocation periodic = builder.setTrigger(Trigger.executionWindow(0, 1)).build();
assertEquals(jobInvocation, periodic);
assertEquals(jobInvocation.hashCode(), periodic.hashCode());
}
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@Test
public void testSchedule_failsWhenPlayServicesIsUnavailable() throws Exception {
markBackendUnavailable();
mockPackageManagerInfo();
Job job = null;
try {
job =
dispatcher
.newJobBuilder()
.setService(TestJobService.class)
.setTag("foobar")
.setConstraints(Constraint.DEVICE_CHARGING)
.setTrigger(Trigger.executionWindow(0, 60))
.build();
} catch (ValidationEnforcer.ValidationException ve) {
fail(TextUtils.join("\n", ve.getErrors()));
}
assertEquals(
"Expected schedule() request to fail when backend is unavailable",
FirebaseJobDispatcher.SCHEDULE_RESULT_NO_DRIVER_AVAILABLE,
dispatcher.schedule(job));
}
内容来源于网络,如有侵权,请联系作者删除!