bolts.Task.cancelled()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(197)

本文整理了Java中bolts.Task.cancelled()方法的一些代码示例,展示了Task.cancelled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.cancelled()方法的具体详情如下:
包路径:bolts.Task
类名称:Task
方法名:cancelled

Task.cancelled介绍

[英]Creates a cancelled task.
[中]创建已取消的任务。

代码示例

代码示例来源:origin: parse-community/Parse-SDK-Android

@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 Task<Void> then(Task<Void> task) {
    if (cancelled.get()) {
      return Task.cancelled();
    }
    return task;
  }
})).cast();

代码示例来源:origin: parse-community/Parse-SDK-Android

@Override
  public Task<Void> then(Task<Void> task) {
    if (cancelled.get()) {
      return Task.cancelled();
    }
    return task;
  }
})).cast();

代码示例来源:origin: parse-community/Parse-SDK-Android

private Task<File> fetchInBackground(
    final ProgressCallback progressCallback,
    Task<Void> toAwait,
    final Task<Void> cancellationToken) {
  if (cancellationToken != null && cancellationToken.isCancelled()) {
    return Task.cancelled();
  }
  return toAwait.continueWithTask(new Continuation<Void, Task<File>>() {
    @Override
    public Task<File> then(Task<Void> task) {
      if (cancellationToken != null && cancellationToken.isCancelled()) {
        return Task.cancelled();
      }
      return getFileController().fetchAsync(
          state,
          null,
          progressCallbackOnMainThread(progressCallback),
          cancellationToken);
    }
  });
}

代码示例来源:origin: parse-community/Parse-SDK-Android

@Override
  public Task<File> then(Task<Void> task) {
    if (cancellationToken != null && cancellationToken.isCancelled()) {
      return Task.cancelled();
    }
    return getFileController().fetchAsync(
        state,
        null,
        progressCallbackOnMainThread(progressCallback),
        cancellationToken);
  }
});

代码示例来源:origin: parse-community/Parse-SDK-Android

final Task<Void> cancellationToken) {
if (cancellationToken != null && cancellationToken.isCancelled()) {
  return Task.cancelled();

代码示例来源:origin: parse-community/Parse-SDK-Android

return Task.cancelled();

代码示例来源:origin: parse-community/Parse-SDK-Android

@Test
public void testSaveAsyncCancelled() throws Exception {
  ParseFileController controller = mock(ParseFileController.class);
  when(controller.isDataAvailable(any(ParseFile.State.class))).thenReturn(true);
  ParseCorePlugins.getInstance().registerFileController(controller);
  ParseFile.State state = new ParseFile.State.Builder().build();
  ParseFile file = new ParseFile(state);
  Task<Void> task = file.saveAsync(null, null, Task.<Void>cancelled());
  task.waitForCompletion();
  assertTrue(task.isCancelled());
  verify(controller, never()).saveAsync(
      any(ParseFile.State.class),
      any(byte[].class),
      any(String.class),
      any(ProgressCallback.class),
      Matchers.<Task<Void>>any());
}

代码示例来源:origin: parse-community/Parse-SDK-Android

@Test
public void testSaveAsyncAlreadyCancelled() throws Exception {
  ParseHttpClient restClient = mock(ParseHttpClient.class);
  ParseFileController controller = new ParseFileController(restClient, null);
  ParseFile.State state = new ParseFile.State.Builder().build();
  Task<Void> cancellationToken = Task.cancelled();
  Task<ParseFile.State> task = controller.saveAsync(state, (byte[]) null, null, null, cancellationToken);
  task.waitForCompletion();
  verify(restClient, times(0)).execute(any(ParseHttpRequest.class));
  assertTrue(task.isCancelled());
}

代码示例来源:origin: parse-community/Parse-SDK-Android

@Test
public void testFetchAsyncAlreadyCancelled() throws Exception {
  ParseHttpClient fileClient = mock(ParseHttpClient.class);
  ParseFileController controller = new ParseFileController(null, null).fileClient(fileClient);
  ParseFile.State state = new ParseFile.State.Builder().build();
  Task<Void> cancellationToken = Task.cancelled();
  Task<File> task = controller.fetchAsync(state, null, null, cancellationToken);
  task.waitForCompletion();
  verify(fileClient, times(0)).execute(any(ParseHttpRequest.class));
  assertTrue(task.isCancelled());
}

代码示例来源:origin: parse-community/Parse-SDK-Android

if (task.isFaulted() && e instanceof ParseException) {
  if (cancellationToken != null && cancellationToken.isCancelled()) {
    return Task.cancelled();

代码示例来源:origin: parse-community/Parse-SDK-Android

final Task<Void> cancellationToken) {
if (cancellationToken != null && cancellationToken.isCancelled()) {
  return Task.cancelled();

代码示例来源:origin: parse-community/Parse-SDK-Android

return Task.cancelled();

代码示例来源:origin: parse-community/ParseUI-Android

@Override
 public Task<List<T>> then(Task<List<T>> task) throws Exception {
  if (ct != null && ct.isCancellationRequested()) {
   return Task.cancelled();
  }
  return task;
 }
});

代码示例来源:origin: parse-community/Parse-SDK-Android

return Task.cancelled();

代码示例来源:origin: parse-community/Parse-SDK-Android

return Task.cancelled();

代码示例来源:origin: mbientlab/MetaWear-SDK-Android

@Override
public Task<Void> resetAsync() {
  EventImpl event = (EventImpl) mwPrivate.getModules().get(EventImpl.class);
  Task<Void> task= (event != null && event.activeDataType != null) ? Task.cancelled() : mwPrivate.boardDisconnect();
  mwPrivate.sendCommand(new byte[] {DEBUG.id, 0x1});
  return task;
}

代码示例来源:origin: mbientlab/MetaWear-SDK-Android

@Override
public Task<Void> disconnectAsync() {
  EventImpl event = (EventImpl) mwPrivate.getModules().get(EventImpl.class);
  Task<Void> task= (event != null && event.activeDataType != null) ? Task.cancelled() : mwPrivate.boardDisconnect();
  mwPrivate.sendCommand(new byte[] {DEBUG.id, 0x6});
  return task;
}

代码示例来源:origin: mbientlab/MetaWear-SDK-Android

@Override
public Task<Void> jumpToBootloaderAsync() {
  EventImpl event = (EventImpl) mwPrivate.getModules().get(EventImpl.class);
  Task<Void> task= (event != null && event.activeDataType != null) ? Task.cancelled() : mwPrivate.boardDisconnect();
  mwPrivate.sendCommand(new byte[] {DEBUG.id, 0x2});
  return task;
}

代码示例来源:origin: fr.avianey/bolts-android-api

@Override
 public Task<Void> then(Task<TResult> task) throws Exception {
  if (task.isCancelled()) {
   return Task.cancelled();
  }
  if (task.isFaulted()) {
   return Task.forError(task.getError());
  }
  return Task.forResult(null);
 }
});

相关文章