本文整理了Java中bolts.Task.continueWithTask()
方法的一些代码示例,展示了Task.continueWithTask()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.continueWithTask()
方法的具体详情如下:
包路径:bolts.Task
类名称:Task
方法名:continueWithTask
[英]Adds an asynchronous continuation to this task, returning a new task that completes after the task returned by the continuation has completed.
[中]将异步延续添加到此任务,返回一个新任务,该任务在延续返回的任务完成后完成。
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<T> then(final Task<T> task) {
return toAwait.continueWithTask(new Continuation<Void, Task<T>>() {
@Override
public Task<T> then(Task<Void> ignored) {
return task;
}
});
}
};
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Void> then(Task<Void> toAwait) {
return toAwait.continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) {
ParseEventuallyQueue cache = Parse.getEventuallyQueue();
return cache.waitForOperationSetAndEventuallyPin(operationSet, null).makeVoid();
}
});
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Boolean> then(Task<Void> toAwait) {
return toAwait.continueWithTask(new Continuation<Void, Task<Boolean>>() {
@Override
public Task<Boolean> then(Task<Void> task) {
return store.existsAsync();
}
});
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Boolean> then(Task<Void> toAwait) {
return toAwait.continueWithTask(new Continuation<Void, Task<Boolean>>() {
@Override
public Task<Boolean> then(Task<Void> task) {
return store.existsAsync();
}
});
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Void> then(final Task<Void> toAwait) {
return runEventuallyAsync(eventuallyPin, toAwait).continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) {
eventuallyPinUUIDQueue.remove(uuid);
return task;
}
});
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
public Task<Integer> pendingCountAsync(Task<Void> toAwait) {
return toAwait.continueWithTask(new Continuation<Void, Task<Integer>>() {
@Override
public Task<Integer> then(Task<Void> task) {
return EventuallyPin.findAllPinned().continueWithTask(new Continuation<List<EventuallyPin>, Task<Integer>>() {
@Override
public Task<Integer> then(Task<List<EventuallyPin>> task) {
List<EventuallyPin> pins = task.getResult();
return Task.forResult(pins.size());
}
});
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Void> then(Task<Void> toAwait) {
return toAwait.continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) {
return store.setAsync(installation);
}
}).continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) {
installationId.set(installation.getInstallationId());
return task;
}
}, ParseExecutors.io());
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Void> setAsync(final T object) {
return ParseObject.unpinAllInBackground(pinName).continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) {
return object.pinInBackground(pinName, false);
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Void> then(Task<Void> toAwait) {
return pendingCountAsync(toAwait).continueWithTask(new Continuation<Integer, Task<Void>>() {
@Override
public Task<Void> then(Task<Integer> task) {
int count = task.getResult();
tcs.setResult(count);
return Task.forResult(null);
}
});
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
private Task<Void> unpinAllObjectsAsync(final String name, final ParseSQLiteDatabase db) {
return getParsePin(name, db).continueWithTask(new Continuation<ParsePin, Task<Void>>() {
@Override
public Task<Void> then(Task<ParsePin> task) {
if (task.isFaulted()) {
return task.makeVoid();
}
ParsePin pin = task.getResult();
return unpinAsync(pin, db);
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<ParseConfig> then(Task<String> task) {
final String sessionToken = task.getResult();
return toAwait.continueWithTask(new Continuation<Void, Task<ParseConfig>>() {
@Override
public Task<ParseConfig> then(Task<Void> task) {
return getConfigController().getAsync(sessionToken);
}
});
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
public Task<Void> await(final Task<Void> task) {
toAwait = toAwait.continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> ignored) {
return task;
}
});
return toAwait;
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Integer> then(Task<Void> task) {
return EventuallyPin.findAllPinned().continueWithTask(new Continuation<List<EventuallyPin>, Task<Integer>>() {
@Override
public Task<Integer> then(Task<List<EventuallyPin>> task) {
List<EventuallyPin> pins = task.getResult();
return Task.forResult(pins.size());
}
});
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
private Task<Void> synchronizeAuthDataAsync(
ParseAuthenticationManager manager, final String authType, Map<String, String> authData) {
return manager.restoreAuthenticationAsync(authType, authData).continueWithTask(new Continuation<Boolean, Task<Void>>() {
@Override
public Task<Void> then(Task<Boolean> task) {
boolean success = !task.isFaulted() && task.getResult();
if (!success) {
return unlinkFromInBackground(authType);
}
return task.makeVoid();
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
private Task<Void> unpinAsync(final ParseObject object, final ParseSQLiteDatabase db) {
Task<String> uuidTask = objectToUuidMap.get(object);
if (uuidTask == null) {
// The root object was never stored in the offline store, so nothing to unpin.
return Task.forResult(null);
}
return uuidTask.continueWithTask(new Continuation<String, Task<Void>>() {
@Override
public Task<Void> then(Task<String> task) {
final String uuid = task.getResult();
if (uuid == null) {
// The root object was never stored in the offline store, so nothing to unpin.
return Task.forResult(null);
}
return unpinAsync(uuid, db);
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
static Task<ParseSQLiteDatabase> openDatabaseAsync(final SQLiteOpenHelper helper, int flags) {
final ParseSQLiteDatabase db = new ParseSQLiteDatabase(flags);
return db.open(helper).continueWithTask(new Continuation<Void, Task<ParseSQLiteDatabase>>() {
@Override
public Task<ParseSQLiteDatabase> then(Task<Void> task) {
return Task.forResult(db);
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<T> then(Task<ParseSQLiteDatabase> task) {
final ParseSQLiteDatabase db = task.getResult();
return callable.call(db).continueWithTask(new Continuation<T, Task<T>>() {
@Override
public Task<T> then(Task<T> task) {
db.closeAsync();
return task;
}
});
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
private Task<Void> upgradeToRevocableSessionAsync(Task<Void> toAwait) {
final String sessionToken = getSessionToken();
return toAwait.continueWithTask(new Continuation<Void, Task<String>>() {
@Override
public Task<String> then(Task<Void> task) {
return ParseSession.upgradeToRevocableSessionAsync(sessionToken);
}
}).onSuccessTask(new Continuation<String, Task<Void>>() {
@Override
public Task<Void> then(Task<String> task) {
String result = task.getResult();
return setSessionTokenInBackground(result);
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Void> deleteAsync() {
final Task<Void> ldsTask = ParseObject.unpinAllInBackground(pinName);
return Task.whenAll(Arrays.asList(
legacy.deleteAsync(),
ldsTask
)).continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) {
// We only really care about the result of unpinning.
return ldsTask;
}
});
}
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<List<EventuallyPin>> then(Task<List<EventuallyPin>> task) {
final List<EventuallyPin> pins = task.getResult();
List<Task<Void>> tasks = new ArrayList<>();
for (EventuallyPin pin : pins) {
ParseObject object = pin.getObject();
if (object != null) {
tasks.add(object.fetchFromLocalDatastoreAsync().makeVoid());
}
}
return Task.whenAll(tasks).continueWithTask(new Continuation<Void, Task<List<EventuallyPin>>>() {
@Override
public Task<List<EventuallyPin>> then(Task<Void> task) {
return Task.forResult(pins);
}
});
}
});
内容来源于网络,如有侵权,请联系作者删除!