本文整理了Java中com.firebase.jobdispatcher.Trigger.contentUriTrigger()
方法的一些代码示例,展示了Trigger.contentUriTrigger()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Trigger.contentUriTrigger()
方法的具体详情如下:
包路径:com.firebase.jobdispatcher.Trigger
类名称:Trigger
方法名:contentUriTrigger
[英]Creates a new ContentUriTrigger based on the provided list of ObservedUri.
[中]根据提供的ObservedUri列表创建新的ContentUriTrigger。
代码示例来源: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
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 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 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 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 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
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: 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: 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);
}
内容来源于网络,如有侵权,请联系作者删除!