本文整理了Java中com.firebase.jobdispatcher.Trigger
类的一些代码示例,展示了Trigger
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Trigger
类的具体详情如下:
包路径:com.firebase.jobdispatcher.Trigger
类名称:Trigger
[英]Generally, a Trigger is an object that can answer the question, "is this job ready to run?"
More specifically, a Trigger is an opaque, abstract class used to root the type hierarchy.
[中]通常,触发器是一个可以回答以下问题的对象:“此作业准备好运行了吗?”
更具体地说,触发器是一个不透明的抽象类,用于作为类型层次结构的根。
代码示例来源: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
@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(expected = IllegalArgumentException.class)
public void constrains_emptyList() throws Exception {
Trigger.contentUriTrigger(Collections.<ObservedUri>emptyList());
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@Test(expected = IllegalArgumentException.class)
public void constrains_null() throws Exception {
Trigger.contentUriTrigger(null);
}
代码示例来源: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 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
static ContentUriTrigger getContentUriTrigger() {
ObservedUri contactUri =
new ObservedUri(ContactsContract.AUTHORITY_URI, Flags.FLAG_NOTIFY_FOR_DESCENDANTS);
ObservedUri imageUri = new ObservedUri(Media.EXTERNAL_CONTENT_URI, 0);
return Trigger.contentUriTrigger(Arrays.asList(contactUri, imageUri));
}
代码示例来源: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
case TIMED_TRIGGER:
builder.setTrigger(
Trigger.executionWindow(form.getWinStartSeconds(), form.getWinEndSeconds()));
break;
case CONTENT_URI_TRIGGER:
notifyForDescendants.isChecked() ? ObservedUri.Flags.FLAG_NOTIFY_FOR_DESCENDANTS : 0;
ObservedUri observedUri = new ObservedUri(uri, flags);
builder.setTrigger(Trigger.contentUriTrigger(Arrays.asList(observedUri)));
break;
default:
代码示例来源:origin: firebase/firebase-jobdispatcher-android
@Test
public void constrains_valid() throws Exception {
List<ObservedUri> uris = Arrays.asList(new ObservedUri(ContactsContract.AUTHORITY_URI, 0));
ContentUriTrigger uriTrigger = Trigger.contentUriTrigger(uris);
assertEquals(uris, uriTrigger.getUris());
}
}
代码示例来源: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 onJobFinished_notRecurringContentJob_sendResult() {
jobInvocationBuilder.setTrigger(
Trigger.contentUriTrigger(Arrays.asList(new ObservedUri(Contacts.CONTENT_URI, 0))));
JobInvocation jobInvocation =
receiver.prepareJob(callbackMock, TestUtil.getBundleForContentJobExecution());
receiver.onJobFinished(jobInvocation, JobService.RESULT_SUCCESS);
verify(callbackMock).jobFinished(JobService.RESULT_SUCCESS);
verifyZeroInteractions(driverMock);
}
代码示例来源: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 testWriteToBundle_contentUriTrigger() {
ObservedUri observedUri =
new ObservedUri(ContactsContract.AUTHORITY_URI, Flags.FLAG_NOTIFY_FOR_DESCENDANTS);
ContentUriTrigger contentUriTrigger = Trigger.contentUriTrigger(Arrays.asList(observedUri));
Bundle bundle =
writer.writeToBundle(
initializeDefaultBuilder().setTrigger(contentUriTrigger).build(), new Bundle());
Uri[] uris = (Uri[]) bundle.getParcelableArray(BundleProtocol.PACKED_PARAM_CONTENT_URI_ARRAY);
int[] flags = bundle.getIntArray(BundleProtocol.PACKED_PARAM_CONTENT_URI_FLAGS_ARRAY);
assertTrue("Array size", uris.length == flags.length && flags.length == 1);
assertEquals(
BundleProtocol.PACKED_PARAM_CONTENT_URI_ARRAY, ContactsContract.AUTHORITY_URI, uris[0]);
assertEquals(
BundleProtocol.PACKED_PARAM_CONTENT_URI_FLAGS_ARRAY,
Flags.FLAG_NOTIFY_FOR_DESCENDANTS,
flags[0]);
}
代码示例来源: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: jberkel/sms-backup-plus
private @NonNull Job createContentUriTriggerJob() {
return createBuilder(INCOMING)
.setTrigger(Trigger.contentUriTrigger(observedUris()))
.setRecurring(true)
.setLifetime(FOREVER)
.setTag(CONTENT_TRIGGER_TAG)
.build();
}
代码示例来源:origin: firebase/firebase-jobdispatcher-android
.setConstraints(Constraint.DEVICE_CHARGING)
.setService(TestJobService.class)
.setTrigger(Trigger.executionWindow(0, 60))
.setRecurring(false)
.setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
代码示例来源:origin: jberkel/sms-backup-plus
@Test
public void testScheduleJobWithUnknownTrigger() throws Exception {
final Job job = jobBuilder()
.setTrigger(Trigger.contentUriTrigger(Collections.singletonList(new ObservedUri(Uri.parse("foo://bar"), 0))))
.build();
final int result = subject.schedule(job);
assertThat(result).isEqualTo(SCHEDULE_RESULT_UNSUPPORTED_TRIGGER);
}
代码示例来源: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))
内容来源于网络,如有侵权,请联系作者删除!