本文整理了Java中bolts.Task.create()
方法的一些代码示例,展示了Task.create()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.create()
方法的具体详情如下:
包路径:bolts.Task
类名称:Task
方法名:create
[英]Creates a TaskCompletionSource that orchestrates a Task. This allows the creator of a task to be solely responsible for its completion.
[中]创建编排任务的TaskCompletionSource。这允许任务的创建者全权负责任务的完成。
代码示例来源:origin: facebook/facebook-android-sdk
final Task<Map<Uri, AppLink>>.TaskCompletionSource taskCompletionSource = Task.create();
代码示例来源:origin: fr.avianey/bolts-android-api
/**
* Invokes the callable using the given executor, returning a Task to represent the operation.
*/
public static <TResult> Task<TResult> call(final Callable<TResult> callable, Executor executor) {
final Task<TResult>.TaskCompletionSource tcs = Task.<TResult> create();
executor.execute(new Runnable() {
@Override
public void run() {
try {
tcs.setResult(callable.call());
} catch (Exception e) {
tcs.setError(e);
}
}
});
return tcs.getTask();
}
代码示例来源:origin: fr.avianey/bolts-android-api
/**
* Creates a faulted task with the given error.
*/
public static <TResult> Task<TResult> forError(Exception error) {
Task<TResult>.TaskCompletionSource tcs = Task.<TResult> create();
tcs.setError(error);
return tcs.getTask();
}
代码示例来源:origin: fr.avianey/bolts-android-api
/**
* Creates a cancelled task.
*/
public static <TResult> Task<TResult> cancelled() {
Task<TResult>.TaskCompletionSource tcs = Task.<TResult> create();
tcs.setCancelled();
return tcs.getTask();
}
代码示例来源:origin: fr.avianey/bolts-android-api
/**
* Creates a completed task with the given value.
*/
public static <TResult> Task<TResult> forResult(TResult value) {
Task<TResult>.TaskCompletionSource tcs = Task.<TResult> create();
tcs.setResult(value);
return tcs.getTask();
}
代码示例来源:origin: fr.avianey/bolts-android-api
final Task<Void>.TaskCompletionSource allFinished = Task.<Void> create();
final ArrayList<Exception> errors = new ArrayList<Exception>();
final Object errorLock = new Object();
代码示例来源: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: fr.avianey/facebook-android-api
final Task<Map<Uri, AppLink>>.TaskCompletionSource taskCompletionSource = Task.create();
代码示例来源: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: parse-community/ParseFacebookUtils-Android
return task;
final Task<T>.TaskCompletionSource tcs = Task.create();
task.continueWith(new Continuation<T, Void>() {
@Override
代码示例来源:origin: com.parse/parsefacebookutils-v3-android
@Deprecated
public synchronized Task<Map<String, String>> extendAccessToken(Context context) {
Task<Map<String, String>>.TaskCompletionSource tcs = Task.create();
if (currentTcs != null) {
handleCancel();
}
currentTcs = tcs;
boolean result = facebook.extendAccessToken(context, new ServiceListener() {
@Override
public void onComplete(Bundle values) {
handleSuccess(userId);
}
@Override
public void onFacebookError(FacebookError e) {
handleError(e);
}
@Override
public void onError(Error e) {
handleError(new ParseException(e));
}
});
if (!result) {
handleCancel();
}
return tcs.getTask();
}
代码示例来源:origin: com.parse/parsefacebookutils-v3-android
return task;
final Task<T>.TaskCompletionSource tcs = Task.create();
task.continueWith(new Continuation<T, Void>() {
@Override
代码示例来源:origin: fr.avianey/bolts-android-api
@Override
public Task<JSONArray> then(Task<Void> task) throws Exception {
final Task<JSONArray>.TaskCompletionSource tcs = Task.create();
final WebView webView = new WebView(context);
webView.getSettings().setJavaScriptEnabled(true);
代码示例来源:origin: com.parse/parsefacebookutils-v3-android
public synchronized Task<Map<String, String>> authenticateAsync() {
Task<Map<String, String>>.TaskCompletionSource tcs = Task.create();
if (currentTcs != null) {
handleCancel();
代码示例来源:origin: parse-community/ParseFacebookUtils-Android
final Task<Map<String, String>>.TaskCompletionSource tcs = Task.create();
LoginManager manager = facebookSdkDelegate.getLoginManager();
内容来源于网络,如有侵权,请联系作者删除!