本文整理了Java中bolts.Task.isCompleted()
方法的一些代码示例,展示了Task.isCompleted()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.isCompleted()
方法的具体详情如下:
包路径:bolts.Task
类名称:Task
方法名:isCompleted
暂无
代码示例来源:origin: facebook/facebook-android-sdk
@Suppress
public void testUrlWithNoAppLinkData() {
String testNoAppLinkUrlString = "https://fb.me/732873156764191_no_app_link";
Uri testNoAppLinkUrl = Uri.parse(testNoAppLinkUrlString);
try {
executeResolverOnBlockerThread(new FacebookAppLinkResolver(), testNoAppLinkUrl);
getTestBlocker().waitForSignals(1);
assertNotNull(resolveTask);
Task<AppLink> singleUrlResolveTask = (Task<AppLink>)resolveTask;
assertTrue(singleUrlResolveTask.isCompleted() &&
!singleUrlResolveTask.isCancelled() &&
!singleUrlResolveTask.isFaulted());
AppLink appLink = singleUrlResolveTask.getResult();
assertNull(appLink);
} catch (Exception e) {
// Forcing the test to fail with details
assertNull(e);
}
}
代码示例来源:origin: parse-community/ParseUI-Android
/**
* @return whether the pager is currently loading the next page.
*/
public boolean isLoadingNextPage() {
synchronized (lock) {
return loadNextPageTask != null && !loadNextPageTask.isCompleted();
}
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Test
public void testCallFunctionAsync() throws Exception {
ParseCloudCodeController controller = mockParseCloudCodeControllerWithResponse("result");
ParseCorePlugins.getInstance().registerCloudCodeController(controller);
Map<String, Object> parameters = new HashMap<>();
parameters.put("key1", Arrays.asList(1, 2, 3));
parameters.put("key2", "value1");
Task cloudCodeTask = ParseCloud.callFunctionInBackground("name", parameters);
ParseTaskUtils.wait(cloudCodeTask);
verify(controller, times(1)).callFunctionInBackground(eq("name"), eq(parameters),
isNull(String.class));
assertTrue(cloudCodeTask.isCompleted());
assertNull(cloudCodeTask.getError());
assertThat(cloudCodeTask.getResult(), instanceOf(String.class));
assertEquals("result", cloudCodeTask.getResult());
}
代码示例来源:origin: parse-community/Parse-SDK-Android
assertFalse(saveTaskA.isCompleted());
queueHelper.dequeue();
ParseTaskUtils.wait(saveTaskA);
assertFalse(getDataTaskA.isCompleted());
queueHelper.dequeue();
ParseTaskUtils.wait(getDataTaskA);
assertFalse(saveTaskB.isCompleted());
queueHelper.dequeue();
ParseTaskUtils.wait(saveTaskB);
assertFalse(getDataTaskB.isCompleted());
queueHelper.dequeue();
ParseTaskUtils.wait(getDataTaskB);
代码示例来源:origin: fr.avianey/bolts-android-api
/**
* Blocks until the task is complete.
*/
public void waitForCompletion() throws InterruptedException {
synchronized (lock) {
if (!isCompleted()) {
lock.wait();
}
}
}
代码示例来源:origin: mbientlab/MetaWear-SDK-Android
public boolean isCompleted() {
return taskSource != null && taskSource.getTask().isCompleted();
}
代码示例来源:origin: mbientlab/MetaWear-SDK-Android
@Override
public Task<Void> localDisconnectAsync() {
Task<Void> task = remoteDisconnectAsync();
if (!task.isCompleted()) {
if (nGattOps.get() > 0) {
readyToClose.set(true);
} else {
if (connectTask.isCompleted()) {
androidBtGatt.disconnect();
} else {
connectTask.cancel();
disconnected(0);
}
}
}
return task;
}
代码示例来源:origin: fr.avianey/bolts-android-api
/**
* Adds an Task-based continuation to this task that will be scheduled using the executor,
* returning a new task that completes after the task returned by the continuation has completed.
*/
public <TContinuationResult> Task<TContinuationResult> continueWithTask(
final Continuation<TResult, Task<TContinuationResult>> continuation, final Executor executor) {
boolean completed = false;
final Task<TContinuationResult>.TaskCompletionSource tcs = Task.<TContinuationResult> create();
synchronized (lock) {
completed = this.isCompleted();
if (!completed) {
this.continuations.add(new Continuation<TResult, Void>() {
@Override
public Void then(Task<TResult> task) {
completeAfterTask(tcs, continuation, task, executor);
return null;
}
});
}
}
if (completed) {
completeAfterTask(tcs, continuation, this, executor);
}
return tcs.getTask();
}
代码示例来源:origin: fr.avianey/bolts-android-api
/**
* Adds a continuation that will be scheduled using the executor, returning a new task that
* completes after the continuation has finished running. This allows the continuation to be
* scheduled on different thread.
*/
public <TContinuationResult> Task<TContinuationResult> continueWith(
final Continuation<TResult, TContinuationResult> continuation, final Executor executor) {
boolean completed = false;
final Task<TContinuationResult>.TaskCompletionSource tcs = Task.<TContinuationResult> create();
synchronized (lock) {
completed = this.isCompleted();
if (!completed) {
this.continuations.add(new Continuation<TResult, Void>() {
@Override
public Void then(Task<TResult> task) {
completeImmediately(tcs, continuation, task, executor);
return null;
}
});
}
}
if (completed) {
completeImmediately(tcs, continuation, this, executor);
}
return tcs.getTask();
}
代码示例来源:origin: mbientlab/MetaWear-SDK-Android
void disconnected(int status) {
closeGatt();
if (!connectTask.isCompleted() && status != 0) {
connectTask.setError(new IllegalStateException(String.format(Locale.US, "Non-zero onConnectionStateChange status (%s)", status)));
} else {
if (disconnectTaskSrc == null || disconnectTaskSrc.getTask().isCompleted()) {
dcHandler.onUnexpectedDisconnect(status);
} else {
dcHandler.onDisconnect();
disconnectTaskSrc.setResult(null);
}
}
}
代码示例来源:origin: mbientlab/MetaWear-SDK-Android
public Task<T> execute(String msgFormat, long timeout, Runnable action) {
if (taskSource != null && !taskSource.getTask().isCompleted()) {
return taskSource.getTask();
}
cts = new CancellationTokenSource();
taskSource = new TaskCompletionSource<>();
action.run();
if (timeout != 0) {
final ArrayList<Task<?>> tasks = new ArrayList<>();
tasks.add(taskSource.getTask());
tasks.add(Task.delay(timeout, cts.getToken()));
Task.whenAny(tasks).continueWith(task -> {
if (task.getResult() != tasks.get(0)) {
setError(new TimeoutException(String.format(msgFormat, timeout)));
} else {
cts.cancel();
}
return null;
});
}
return taskSource.getTask();
}
代码示例来源:origin: parse-community/ParseFacebookUtils-Android
@Test
public void testLinkWithAccessToken() {
Map<String, String> authData = new HashMap<>();
when(controller.getAuthData(any(AccessToken.class))).thenReturn(authData);
ParseFacebookUtils.isInitialized = true;
ParseUser user = mock(ParseUser.class);
when(user.linkWithInBackground(anyString(), anyMapOf(String.class, String.class)))
.thenReturn(Task.<Void>forResult(null));
AccessToken token = TestUtils.newAccessToken();
Task<Void> task = ParseFacebookUtils.linkInBackground(user, token);
verify(controller).getAuthData(token);
verify(user).linkWithInBackground("facebook", authData);
assertTrue(task.isCompleted());
}
代码示例来源:origin: parse-community/ParseFacebookUtils-Android
@Test
public void testLogInWithAccessToken() {
Map<String, String> authData = new HashMap<>();
when(controller.getAuthData(any(AccessToken.class))).thenReturn(authData);
ParseFacebookUtils.isInitialized = true;
ParseUser user = mock(ParseUser.class);
when(userDelegate.logInWithInBackground(anyString(), anyMapOf(String.class, String.class)))
.thenReturn(Task.forResult(user));
AccessToken token = TestUtils.newAccessToken();
Task<ParseUser> task = ParseFacebookUtils.logInInBackground(token);
verify(controller).getAuthData(token);
verify(userDelegate).logInWithInBackground("facebook", authData);
assertTrue(task.isCompleted());
assertEquals(user, task.getResult());
}
代码示例来源:origin: parse-community/ParseFacebookUtils-Android
when(loginResult.getAccessToken()).thenReturn(accessToken);
callback.onSuccess(loginResult);
assertTrue(task.isCompleted());
代码示例来源:origin: parse-community/ParseFacebookUtils-Android
assertTrue(task.isCompleted());
assertEquals(user, task.getResult());
代码示例来源:origin: parse-community/ParseFacebookUtils-Android
assertTrue(task.isCompleted());
代码示例来源:origin: mbientlab/MetaWear-SDK-Android
@Override
public Task<Void> connectAsync() {
if (connectTask != null && !connectTask.isCompleted()) {
return connectTask;
内容来源于网络,如有侵权,请联系作者删除!