本文整理了Java中bolts.Task.onSuccess()
方法的一些代码示例,展示了Task.onSuccess()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.onSuccess()
方法的具体详情如下:
包路径:bolts.Task
类名称:Task
方法名:onSuccess
[英]Runs a continuation when a task completes successfully, forwarding along errors or cancellation.
[中]
代码示例来源:origin: facebook/facebook-android-sdk
/**
* Asynchronously resolves App Link data for the passed in Uri
*
* @param uri Uri to be resolved into an App Link
* @return A Task that, when successful, will return an AppLink for the passed in Uri. This may
* be null if no App Link data was found for this Uri. In the case of general server errors, the
* task will be completed with the corresponding error.
*/
public Task<AppLink> getAppLinkFromUrlInBackground(final Uri uri) {
ArrayList<Uri> uris = new ArrayList<Uri>();
uris.add(uri);
Task<Map<Uri, AppLink>> resolveTask = getAppLinkFromUrlsInBackground(uris);
return resolveTask.onSuccess(new Continuation<Map<Uri, AppLink>, AppLink>() {
@Override
public AppLink then(Task<Map<Uri, AppLink>> resolveUrisTask) throws Exception {
return resolveUrisTask.getResult().get(uri);
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Boolean> matchesAsync(T object, ParseSQLiteDatabase db) {
return inQueryMatcher.matchesAsync(object, db).onSuccess(new Continuation<Boolean, Boolean>() {
@Override
public Boolean then(Task<Boolean> task) {
return !task.getResult();
}
});
}
};
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<String> getCurrentSessionTokenAsync() {
return getAsync(false).onSuccess(new Continuation<ParseUser, String>() {
@Override
public String then(Task<ParseUser> task) {
ParseUser user = task.getResult();
return user != null ? user.getSessionToken() : null;
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Boolean> matchesAsync(T object, ParseSQLiteDatabase db) {
return selectMatcher.matchesAsync(object, db).onSuccess(new Continuation<Boolean, Boolean>() {
@Override
public Boolean then(Task<Boolean> task) {
return !task.getResult();
}
});
}
};
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Integer> then(Task<ParsePin> task) {
ParsePin pin = task.getResult();
return findAsync(state, user, pin, true, db).onSuccess(new Continuation<List<T>, Integer>() {
@Override
public Integer then(Task<List<T>> task) {
return task.getResult().size();
}
});
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Boolean> matchesAsync(final T object, ParseSQLiteDatabase db) {
/*
* As an optimization, we do this lazily. Then we may not have to do it at all, if this part
* of the query gets short-circuited.
*/
if (subQueryResults == null) {
//TODO (grantland): We need to pass through the original pin we were limiting the parent
// query on.
subQueryResults = store.findAsync(subQuery, user, null, db);
}
return subQueryResults.onSuccess(new Continuation<List<T>, Boolean>() {
@Override
public Boolean then(Task<List<T>> task) throws ParseException {
return matches(object, task.getResult());
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<ParseUser> then(Task<State> task) {
State result = task.getResult();
final ParseUser newCurrent = ParseObject.from(result);
return saveCurrentUserAsync(newCurrent).onSuccess(new Continuation<Void, ParseUser>() {
@Override
public ParseUser then(Task<Void> task) {
return newCurrent;
}
});
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<ParseUser> then(Task<State> task) {
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
@Override
public Task<ParseObject.State> getSessionAsync(String sessionToken) {
ParseRESTSessionCommand command =
ParseRESTSessionCommand.getCurrentSessionCommand(sessionToken);
return command.executeAsync(client).onSuccess(new Continuation<JSONObject, ParseObject.State>() {
@Override
public ParseObject.State then(Task<JSONObject> task) {
JSONObject result = task.getResult();
return coder.decode(new ParseObject.State.Builder("_Session"), result, ParseDecoder.get())
.isComplete(true)
.build();
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<ParseUser.State> getUserAsync(String sessionToken) {
ParseRESTCommand command = ParseRESTUserCommand.getCurrentUserCommand(sessionToken);
return command.executeAsync(client).onSuccess(new Continuation<JSONObject, ParseUser.State>() {
@Override
public ParseUser.State then(Task<JSONObject> task) {
JSONObject result = task.getResult();
return coder.decode(new ParseUser.State.Builder(), result, ParseDecoder.get())
.isComplete(true)
.build();
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
public <T> Task<T> callFunctionInBackground(final String name,
final Map<String, ?> params, String sessionToken) {
ParseRESTCommand command = ParseRESTCloudCommand.callFunctionCommand(
name,
params,
sessionToken);
return command.executeAsync(restClient).onSuccess(new Continuation<JSONObject, T>() {
@Override
public T then(Task<JSONObject> task) {
@SuppressWarnings("unchecked")
T result = (T) convertCloudResponse(task.getResult());
return result;
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<ParseUser.State> logInAsync(
String username, String password) {
ParseRESTCommand command = ParseRESTUserCommand.logInUserCommand(
username, password, revocableSession);
return command.executeAsync(client).onSuccess(new Continuation<JSONObject, ParseUser.State>() {
@Override
public ParseUser.State then(Task<JSONObject> task) {
JSONObject result = task.getResult();
return coder.decode(new ParseUser.State.Builder(), result, ParseDecoder.get())
.isComplete(true)
.build();
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<ParseObject.State> upgradeToRevocable(String sessionToken) {
ParseRESTSessionCommand command =
ParseRESTSessionCommand.upgradeToRevocableSessionCommand(sessionToken);
return command.executeAsync(client).onSuccess(new Continuation<JSONObject, ParseObject.State>() {
@Override
public ParseObject.State then(Task<JSONObject> task) {
JSONObject result = task.getResult();
return coder.decode(new ParseObject.State.Builder("_Session"), result, ParseDecoder.get())
.isComplete(true)
.build();
}
});
}
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<ParseUser.State> logInAsync(
final String authType, final Map<String, String> authData) {
final ParseRESTUserCommand command = ParseRESTUserCommand.serviceLogInUserCommand(
authType, authData, revocableSession);
return command.executeAsync(client).onSuccess(new Continuation<JSONObject, ParseUser.State>() {
@Override
public ParseUser.State then(Task<JSONObject> task) {
JSONObject result = task.getResult();
return coder.decode(new ParseUser.State.Builder(), result, ParseDecoder.get())
.isComplete(true)
.isNew(command.getStatusCode() == STATUS_CODE_CREATED)
.putAuthData(authType, authData)
.build();
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<ParseSession> then(Task<String> task) {
String sessionToken = task.getResult();
if (sessionToken == null) {
return Task.forResult(null);
}
return getSessionController().getSessionAsync(sessionToken).onSuccess(new Continuation<ParseObject.State, ParseSession>() {
@Override
public ParseSession then(Task<ParseObject.State> task) {
ParseObject.State result = task.getResult();
return ParseObject.from(result);
}
});
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
static Task<String> upgradeToRevocableSessionAsync(String sessionToken) {
if (sessionToken == null || isRevocableSessionToken(sessionToken)) {
return Task.forResult(sessionToken);
}
return getSessionController().upgradeToRevocable(sessionToken).onSuccess(new Continuation<ParseObject.State, String>() {
@Override
public String then(Task<ParseObject.State> task) {
ParseObject.State result = task.getResult();
return ParseObject.<ParseSession>from(result).getSessionToken();
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
/**
* Executes a DELETE.
*
* @see SQLiteDatabase#delete
*/
public Task<Void> deleteAsync(final String table, final String where, final String[] args) {
synchronized (currentLock) {
Task<Integer> task = current.onSuccess(new Continuation<Void, Integer>() {
@Override
public Integer then(Task<Void> task) {
return db.delete(table, where, args);
}
}, dbExecutor);
current = task.makeVoid();
return task.continueWithTask(new Continuation<Integer, Task<Integer>>() {
@Override
public Task<Integer> then(Task<Integer> task) {
// We want to jump off the dbExecutor
return task;
}
}, Task.BACKGROUND_EXECUTOR).makeVoid();
}
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<ParseObject.State> fetchAsync(
final ParseObject.State state, String sessionToken, final ParseDecoder decoder) {
final ParseRESTCommand command = ParseRESTObjectCommand.getObjectCommand(
state.objectId(),
state.className(),
sessionToken);
return command.executeAsync(client).onSuccess(new Continuation<JSONObject, ParseObject.State>() {
@Override
public ParseObject.State then(Task<JSONObject> task) {
JSONObject result = task.getResult();
// Copy and clear to create an new empty instance of the same type as `state`
ParseObject.State.Init<?> builder = state.newBuilder().clear();
return coder.decode(builder, result, decoder)
.isComplete(true)
.build();
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<ParseUser.State> signUpAsync(
final ParseObject.State state,
ParseOperationSet operations,
String sessionToken) {
JSONObject objectJSON = coder.encode(state, operations, PointerEncoder.get());
ParseRESTCommand command = ParseRESTUserCommand.signUpUserCommand(
objectJSON, sessionToken, revocableSession);
return command.executeAsync(client).onSuccess(new Continuation<JSONObject, ParseUser.State>() {
@Override
public ParseUser.State then(Task<JSONObject> task) {
JSONObject result = task.getResult();
return coder.decode(new ParseUser.State.Builder(), result, ParseDecoder.get())
.isComplete(false)
.isNew(true)
.build();
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<ParseUser.State> logInAsync(
ParseUser.State state, ParseOperationSet operations) {
JSONObject objectJSON = coder.encode(state, operations, PointerEncoder.get());
final ParseRESTUserCommand command = ParseRESTUserCommand.serviceLogInUserCommand(
objectJSON, state.sessionToken(), revocableSession);
return command.executeAsync(client).onSuccess(new Continuation<JSONObject, ParseUser.State>() {
@Override
public ParseUser.State then(Task<JSONObject> task) {
JSONObject result = task.getResult();
// TODO(grantland): Does the server really respond back with complete object data if the
// object isn't new?
boolean isNew = command.getStatusCode() == STATUS_CODE_CREATED;
boolean isComplete = !isNew;
return coder.decode(new ParseUser.State.Builder(), result, ParseDecoder.get())
.isComplete(isComplete)
.isNew(isNew)
.build();
}
});
}
内容来源于网络,如有侵权,请联系作者删除!