本文整理了Java中bolts.Task.cast()
方法的一些代码示例,展示了Task.cast()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.cast()
方法的具体详情如下:
包路径:bolts.Task
类名称:Task
方法名:cast
[英]Makes a fluent cast of a Task's result possible, avoiding an extra continuation just to cast the type of the result.
[中]使任务结果的流畅转换成为可能,避免为了转换结果类型而进行额外的延续。
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<T> getAsync() {
// 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.findInBackground().onSuccessTask(new Continuation<List<T>, Task<T>>() {
@Override
public Task<T> then(Task<List<T>> task) {
List<T> results = task.getResult();
if (results != null) {
if (results.size() == 1) {
return Task.forResult(results.get(0));
} else {
return ParseObject.unpinAllInBackground(pinName).cast();
}
}
return Task.forResult(null);
}
}).onSuccessTask(new Continuation<T, Task<T>>() {
@Override
public Task<T> then(Task<T> task) {
T ldsObject = task.getResult();
if (ldsObject != null) {
return task;
}
return migrate(legacy, OfflineObjectStore.this).cast();
}
});
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public <T extends ParseObject> Task<Integer> countAsync(ParseQuery.State<T> state,
ParseUser user, Task<Void> cancellationToken) {
final AtomicBoolean cancelled = new AtomicBoolean(false);
cancellationToken.continueWith(new Continuation<Void, Void>() {
@Override
public Void then(Task<Void> task) {
cancelled.set(true);
return null;
}
});
return await(Task.<Void>forResult(null).continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) {
if (cancelled.get()) {
return Task.cancelled();
}
return task;
}
})).cast();
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public <T extends ParseObject> Task<List<T>> findAsync(ParseQuery.State<T> state,
ParseUser user, Task<Void> cancellationToken) {
final AtomicBoolean cancelled = new AtomicBoolean(false);
cancellationToken.continueWith(new Continuation<Void, Void>() {
@Override
public Void then(Task<Void> task) {
cancelled.set(true);
return null;
}
});
return await(Task.<Void>forResult(null).continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) {
if (cancelled.get()) {
return Task.cancelled();
}
return task;
}
})).cast();
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public <T extends ParseObject> Task<T> getFirstAsync(ParseQuery.State<T> state,
ParseUser user, Task<Void> cancellationToken) {
final AtomicBoolean cancelled = new AtomicBoolean(false);
cancellationToken.continueWith(new Continuation<Void, Void>() {
@Override
public Void then(Task<Void> task) {
cancelled.set(true);
return null;
}
});
return await(Task.<Void>forResult(null).continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) {
if (cancelled.get()) {
return Task.cancelled();
}
return task;
}
})).cast();
}
}
代码示例来源:origin: parse-community/Parse-SDK-Android
executeTask = object.saveAsync(httpClient, operationSet, sessionToken);
} else if (type == EventuallyPin.TYPE_DELETE) {
executeTask = object.deleteAsync(sessionToken).cast();
} else { // else if (type == EventuallyPin.TYPE_COMMAND) {
ParseRESTCommand command = eventuallyPin.getCommand();
内容来源于网络,如有侵权,请联系作者删除!