本文整理了Java中bolts.Task.onSuccessTask()
方法的一些代码示例,展示了Task.onSuccessTask()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.onSuccessTask()
方法的具体详情如下:
包路径:bolts.Task
类名称:Task
方法名:onSuccessTask
[英]Runs a continuation when a task completes successfully, forwarding along errors or cancellation.
[中]当任务成功完成时运行延续,转发错误或取消。
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<List<T>> call() {
return getUserAsync(state).onSuccessTask(new Continuation<ParseUser, Task<List<T>>>() {
@Override
public Task<List<T>> then(Task<ParseUser> task) {
final ParseUser user = task.getResult();
return findAsync(state, user, tcs.getTask());
}
});
}
}, tcs);
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Integer> call() {
return getUserAsync(state).onSuccessTask(new Continuation<ParseUser, Task<Integer>>() {
@Override
public Task<Integer> then(Task<ParseUser> task) {
final ParseUser user = task.getResult();
return countAsync(state, user, tcs.getTask());
}
});
}
}, tcs);
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
/* package */ Task<Void> handleFetchResultAsync(final ParseObject.State newState) {
return super.handleFetchResultAsync(newState).onSuccessTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) {
return getCurrentInstallationController().setAsync(ParseInstallation.this);
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<T> call() {
return getUserAsync(state).onSuccessTask(new Continuation<ParseUser, Task<T>>() {
@Override
public Task<T> then(Task<ParseUser> task) {
final ParseUser user = task.getResult();
return getFirstAsync(state, user, tcs.getTask());
}
});
}
}, tcs);
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
/* package */ Task<Void> handleSaveResultAsync(ParseObject.State result,
ParseOperationSet operationsBeforeSave) {
Task<Void> task = super.handleSaveResultAsync(result, operationsBeforeSave);
if (result == null) { // Failure
return task;
}
return task.onSuccessTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) {
return getCurrentInstallationController().setAsync(ParseInstallation.this);
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
private static Task<ParseConfig> getAsync(final Task<Void> toAwait) {
return ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation<String, Task<ParseConfig>>() {
@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
private static <T extends ParseObject> Task<List<T>> fetchAllAsync(
final List<T> objects, final boolean onlyIfNeeded) {
return ParseUser.getCurrentUserAsync().onSuccessTask(new Continuation<ParseUser, Task<List<T>>>() {
@Override
public Task<List<T>> then(Task<ParseUser> task) {
final ParseUser user = task.getResult();
return enqueueForAll(objects, new Continuation<Void, Task<List<T>>>() {
@Override
public Task<List<T>> then(Task<Void> task) {
return fetchAllAsync(objects, user, onlyIfNeeded, task);
}
});
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Boolean> matchesAsync(final T object, final ParseSQLiteDatabase db) {
Task<Boolean> task = Task.forResult(false);
for (final ConstraintMatcher<T> matcher : matchers) {
task = task.onSuccessTask(new Continuation<Boolean, Task<Boolean>>() {
@Override
public Task<Boolean> then(Task<Boolean> task) {
if (task.getResult()) {
return task;
}
return matcher.matchesAsync(object, db);
}
});
}
return task;
}
};
代码示例来源:origin: parse-community/Parse-SDK-Android
/**
* Deletes each object in the provided list. This is faster than deleting each object individually
* because it batches the requests.
*
* @param objects The objects to delete.
* @return A {@link bolts.Task} that is resolved when deleteAll completes.
*/
public static <T extends ParseObject> Task<Void> deleteAllInBackground(final List<T> objects) {
return ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation<String, Task<Void>>() {
@Override
public Task<Void> then(Task<String> task) {
String sessionToken = task.getResult();
return deleteAllAsync(objects, sessionToken);
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Boolean> matchesAsync(final T object, final ParseSQLiteDatabase db) {
Task<Boolean> task = Task.forResult(true);
for (final ConstraintMatcher<T> matcher : matchers) {
task = task.onSuccessTask(new Continuation<Boolean, Task<Boolean>>() {
@Override
public Task<Boolean> then(Task<Boolean> task) {
if (!task.getResult()) {
return task;
}
return matcher.matchesAsync(object, db);
}
});
}
return task;
}
};
代码示例来源:origin: parse-community/Parse-SDK-Android
/**
* Calls a cloud function in the background.
*
* @param name The cloud function to call.
* @param params The parameters to send to the cloud function. This map can contain anything that could
* be placed in a ParseObject except for ParseObjects themselves.
* @return A Task that will be resolved when the cloud function has returned.
*/
public static <T> Task<T> callFunctionInBackground(final String name,
final Map<String, ?> params) {
return ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation<String, Task<T>>() {
@Override
public Task<T> then(Task<String> task) {
String sessionToken = task.getResult();
return getCloudCodeController().callFunctionInBackground(name, params, sessionToken);
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
/**
* Wraps SQLite operations with a managed SQLite connection.
*/
private <T> Task<T> runWithManagedConnection(final SQLiteDatabaseCallable<Task<T>> callable) {
return helper.getWritableDatabaseAsync().onSuccessTask(new Continuation<ParseSQLiteDatabase, Task<T>>() {
@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> populateQueueAsync(Task<Void> toAwait) {
return toAwait.continueWithTask(new Continuation<Void, Task<List<EventuallyPin>>>() {
@Override
public Task<List<EventuallyPin>> then(Task<Void> task) {
// We don't want to enqueue any EventuallyPins that are already queued.
return EventuallyPin.findAllPinned(eventuallyPinUUIDQueue);
}
}).onSuccessTask(new Continuation<List<EventuallyPin>, Task<Void>>() {
@Override
public Task<Void> then(Task<List<EventuallyPin>> task) {
List<EventuallyPin> pins = task.getResult();
for (final EventuallyPin pin : pins) {
// We don't need to wait for this.
runEventuallyAsync(pin);
}
return task.makeVoid();
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
/**
* Handles the result of {@code deleteEventually}.
* <p>
* Should only be called on success.
*/
Task<Void> handleDeleteEventuallyResultAsync() {
synchronized (mutex) {
isDeletingEventually -= 1;
}
Task<Void> handleDeleteResultTask = handleDeleteResultAsync();
return handleDeleteResultTask.onSuccessTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) {
Parse.getEventuallyQueue()
.notifyTestHelper(ParseCommandCache.TestHelper.OBJECT_REMOVED);
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
/**
* Sends this push notification in a background thread. Use this when you do not have code to run
* on completion of the push.
*
* @return A Task is resolved when the push has been sent.
*/
public Task<Void> sendInBackground() {
// Since getCurrentSessionTokenAsync takes time, we build the state before it.
final State state = builder.build();
return ParseUser.getCurrentSessionTokenAsync().onSuccessTask(new Continuation<String, Task<Void>>() {
@Override
public Task<Void> then(Task<String> task) {
String sessionToken = task.getResult();
return getPushController().sendInBackground(state, sessionToken);
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
public Task<ParseConfig> getAsync(String sessionToken) {
final ParseRESTCommand command = ParseRESTConfigCommand.fetchConfigCommand(sessionToken);
return command.executeAsync(restClient).onSuccessTask(new Continuation<JSONObject, Task<ParseConfig>>() {
@Override
public Task<ParseConfig> then(Task<JSONObject> task) {
JSONObject result = task.getResult();
final ParseConfig config = ParseConfig.decode(result, ParseDecoder.get());
return currentConfigController.setCurrentConfigAsync(config).continueWith(new Continuation<Void, ParseConfig>() {
@Override
public ParseConfig then(Task<Void> task) {
return config;
}
});
}
});
}
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<ParseUser> then(Task<Void> task) {
return getUserController().logInAsync(authType, authData).onSuccessTask(new Continuation<ParseUser.State, Task<ParseUser>>() {
@Override
public Task<ParseUser> then(Task<ParseUser.State> task) {
ParseUser.State result = task.getResult();
final ParseUser user = ParseObject.from(result);
return saveCurrentUserAsync(user).onSuccess(new Continuation<Void, ParseUser>() {
@Override
public ParseUser then(Task<Void> task) {
return user;
}
});
}
});
}
};
代码示例来源:origin: parse-community/Parse-SDK-Android
private <T extends ParseObject> Task<List<T>> findFromPinAsync(
final String name,
final ParseQuery.State<T> state,
final ParseUser user,
final ParseSQLiteDatabase db) {
Task<ParsePin> task;
if (name != null) {
task = getParsePin(name, db);
} else {
task = Task.forResult(null);
}
return task.onSuccessTask(new Continuation<ParsePin, Task<List<T>>>() {
@Override
public Task<List<T>> then(Task<ParsePin> task) {
ParsePin pin = task.getResult();
return findAsync(state, user, pin, false, db);
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Boolean> existsAsync() {
// We need to set `ignoreACLs` since we can't use ACLs without the current user.
ParseQuery<T> query = ParseQuery.<T>getQuery(className)
.fromPin(pinName)
.ignoreACLs();
return query.countInBackground().onSuccessTask(new Continuation<Integer, Task<Boolean>>() {
@Override
public Task<Boolean> then(Task<Integer> task) {
boolean exists = task.getResult() == 1;
if (exists) {
return Task.forResult(true);
}
return legacy.existsAsync();
}
});
}
内容来源于网络,如有侵权,请联系作者删除!