本文整理了Java中bolts.Task.makeVoid()
方法的一些代码示例,展示了Task.makeVoid()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.makeVoid()
方法的具体详情如下:
包路径:bolts.Task
类名称:Task
方法名:makeVoid
[英]Turns a Task into a Task, dropping any result.
[中]将任务转换为任务,删除任何结果。
代码示例来源:origin: parse-community/Parse-SDK-Android
public Task<Boolean> isReadOnlyAsync() {
synchronized (currentLock) {
Task<Boolean> task = current.continueWith(new Continuation<Void, Boolean>() {
@Override
public Boolean then(Task<Void> task) {
return db.isReadOnly();
}
});
current = task.makeVoid();
return task;
}
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Void> then(Task<Void> task) {
return store.fetchLocallyAsync(ParseObject.this).makeVoid();
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
public Task<Boolean> isOpenAsync() {
synchronized (currentLock) {
Task<Boolean> task = current.continueWith(new Continuation<Void, Boolean>() {
@Override
public Boolean then(Task<Void> task) {
return db.isOpen();
}
});
current = task.makeVoid();
return task;
}
}
代码示例来源: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
/**
* Executes an INSERT and throws on SQL errors.
*
* @see SQLiteDatabase#insertOrThrow
*/
public Task<Void> insertOrThrowAsync(final String table, final ContentValues values) {
synchronized (currentLock) {
Task<Long> task = current.onSuccess(new Continuation<Void, Long>() {
@Override
public Long then(Task<Void> task) {
return db.insertOrThrow(table, null, values);
}
}, dbExecutor);
current = task.makeVoid();
return task.continueWithTask(new Continuation<Long, Task<Long>>() {
@Override
public Task<Long> then(Task<Long> task) {
// We want to jump off the dbExecutor
return task;
}
}, Task.BACKGROUND_EXECUTOR).makeVoid();
}
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public List<Task<Void>> deleteAllAsync(
List<ParseObject.State> states, String sessionToken) {
int batchSize = states.size();
List<ParseRESTObjectCommand> commands = new ArrayList<>(batchSize);
for (int i = 0; i < batchSize; i++) {
ParseObject.State state = states.get(i);
ParseRESTObjectCommand command = ParseRESTObjectCommand.deleteObjectCommand(
state, sessionToken);
commands.add(command);
}
final List<Task<JSONObject>> batchTasks =
ParseRESTObjectBatchCommand.executeBatch(client, commands, sessionToken);
List<Task<Void>> tasks = new ArrayList<>(batchSize);
for (int i = 0; i < batchSize; i++) {
tasks.add(batchTasks.get(i).makeVoid());
}
return tasks;
}
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Void> then(Task<Void> task) throws Exception {
// Put the JSON in the database.
String className = object.getClassName();
String objectId = object.getObjectId();
int isDeletingEventually = json.getInt(ParseObject.KEY_IS_DELETING_EVENTUALLY);
final ContentValues values = new ContentValues();
values.put(OfflineSQLiteOpenHelper.KEY_CLASS_NAME, className);
values.put(OfflineSQLiteOpenHelper.KEY_JSON, json.toString());
if (objectId != null) {
values.put(OfflineSQLiteOpenHelper.KEY_OBJECT_ID, objectId);
}
values.put(OfflineSQLiteOpenHelper.KEY_IS_DELETING_EVENTUALLY, isDeletingEventually);
String where = OfflineSQLiteOpenHelper.KEY_UUID + " = ?";
String[] args = {uuid};
return db.updateAsync(OfflineSQLiteOpenHelper.TABLE_OBJECTS, values, where, args).makeVoid();
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Void> revokeAsync(String sessionToken) {
return ParseRESTSessionCommand.revoke(sessionToken)
.executeAsync(client)
.makeVoid();
}
代码示例来源:origin: parse-community/Parse-SDK-Android
public Task<Void> trackAppOpenedInBackground(String pushHash, String sessionToken) {
ParseRESTCommand command = ParseRESTAnalyticsCommand.trackAppOpenedCommand(pushHash,
sessionToken);
Task<JSONObject> eventuallyTask = eventuallyQueue.enqueueEventuallyAsync(command, null);
return eventuallyTask.makeVoid();
}
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Override
public Task<Void> requestPasswordResetAsync(String email) {
ParseRESTCommand command = ParseRESTUserCommand.resetPasswordResetCommand(email);
return command.executeAsync(client).makeVoid();
}
}
代码示例来源:origin: parse-community/Parse-SDK-Android
public Task<Void> trackEventInBackground(final String name,
Map<String, String> dimensions, String sessionToken) {
ParseRESTCommand command = ParseRESTAnalyticsCommand.trackEventCommand(name, dimensions,
sessionToken);
Task<JSONObject> eventuallyTask = eventuallyQueue.enqueueEventuallyAsync(command, null);
return eventuallyTask.makeVoid();
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@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<Void> deleteAsync(ParseObject.State state, String sessionToken) {
ParseRESTObjectCommand command = ParseRESTObjectCommand.deleteObjectCommand(
state, sessionToken);
return command.executeAsync(client).makeVoid();
}
代码示例来源:origin: parse-community/Parse-SDK-Android
public Task<Void> sendInBackground(ParsePush.State state, String sessionToken) {
return buildRESTSendPushCommand(state, sessionToken).executeAsync(restClient).makeVoid();
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@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
/**
* Executes an UPDATE.
*
* @see SQLiteDatabase#update
*/
public Task<Integer> updateAsync(final String table, final ContentValues values,
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.update(table, values, 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);
}
}
代码示例来源: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);
}
});
}
});
代码示例来源:origin: parse-community/Parse-SDK-Android
/* package for tests */ Task<Void> cleanUpAuthDataAsync() {
ParseAuthenticationManager controller = getAuthenticationManager();
Map<String, Map<String, String>> authData;
synchronized (mutex) {
authData = getState().authData();
if (authData.size() == 0) {
return Task.forResult(null); // Nothing to see or do here...
}
}
List<Task<Void>> tasks = new ArrayList<>();
Iterator<Map.Entry<String, Map<String, String>>> i = authData.entrySet().iterator();
while (i.hasNext()) {
Map.Entry<String, Map<String, String>> entry = i.next();
if (entry.getValue() == null) {
i.remove();
tasks.add(controller.restoreAuthenticationAsync(entry.getKey(), null).makeVoid());
}
}
State newState = getState().newBuilder()
.authData(authData)
.build();
setState(newState);
return Task.whenAll(tasks);
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Test
public void testMultipleQueriesWithInflightChanges() throws ParseException {
Parse.enableLocalDatastore(null);
TestQueryController controller = new TestQueryController();
TaskCompletionSource<Void> tcs = new TaskCompletionSource<>();
controller.await(tcs.getTask());
ParseQuery<ParseObject> query = ParseQuery.getQuery("TestObject");
query.setUser(new ParseUser());
ParseCorePlugins.getInstance().registerQueryController(controller);
List<Task<Void>> tasks = Arrays.asList(
query.fromNetwork().findInBackground().makeVoid(),
query.fromLocalDatastore().findInBackground().makeVoid(),
query.setLimit(10).findInBackground().makeVoid(),
query.whereEqualTo("key", "value").countInBackground().makeVoid());
assertTrue(query.isRunning());
tcs.trySetResult(null);
ParseTaskUtils.wait(Task.whenAll(tasks));
assertFalse(query.isRunning());
}
代码示例来源:origin: parse-community/Parse-SDK-Android
@Test
public void testQueryCancellation() throws ParseException {
TestQueryController controller = new TestQueryController();
ParseCorePlugins.getInstance().registerQueryController(controller);
TaskCompletionSource<Void> tcs = new TaskCompletionSource();
controller.await(tcs.getTask());
ParseQuery<ParseObject> query = ParseQuery.getQuery("TestObject");
query.setUser(new ParseUser());
Task<Void> task = query.findInBackground().makeVoid();
query.cancel();
tcs.setResult(null);
try {
ParseTaskUtils.wait(task);
} catch (RuntimeException e) {
assertThat(e.getCause(), instanceOf(CancellationException.class));
}
// Should succeed
task = query.findInBackground().makeVoid();
ParseTaskUtils.wait(task);
}
内容来源于网络,如有侵权,请联系作者删除!