retrofit2.Call.cancel()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(303)

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

Call.cancel介绍

[英]Cancel this call. An attempt will be made to cancel in-flight calls, and if the call has not yet been executed it never will be.
[中]取消这个电话。将尝试取消飞行中的呼叫,如果呼叫尚未执行,则永远不会执行。

代码示例

代码示例来源:origin: square/retrofit

  1. @Override protected void interruptTask() {
  2. call.cancel();
  3. }
  4. };

代码示例来源:origin: square/retrofit

  1. @Override public void dispose() {
  2. disposed = true;
  3. call.cancel();
  4. }

代码示例来源:origin: square/retrofit

  1. @Override protected void interruptTask() {
  2. call.cancel();
  3. }
  4. };

代码示例来源:origin: square/retrofit

  1. @Override public void unsubscribe() {
  2. unsubscribed = true;
  3. call.cancel();
  4. }

代码示例来源:origin: square/retrofit

  1. @Override public void cancel() {
  2. delegate.cancel();
  3. }

代码示例来源:origin: square/retrofit

  1. @Override public void cancel() {
  2. call.cancel();
  3. }

代码示例来源:origin: square/retrofit

  1. @Override public void dispose() {
  2. disposed = true;
  3. call.cancel();
  4. }

代码示例来源:origin: square/retrofit

  1. @Override public boolean cancel(boolean mayInterruptIfRunning) {
  2. if (mayInterruptIfRunning) {
  3. call.cancel();
  4. }
  5. return super.cancel(mayInterruptIfRunning);
  6. }
  7. };

代码示例来源:origin: square/retrofit

  1. @Override public boolean cancel(boolean mayInterruptIfRunning) {
  2. if (mayInterruptIfRunning) {
  3. call.cancel();
  4. }
  5. return super.cancel(mayInterruptIfRunning);
  6. }
  7. };

代码示例来源:origin: square/retrofit

  1. @Override public boolean cancel(boolean mayInterruptIfRunning) {
  2. if (mayInterruptIfRunning) {
  3. call.cancel();
  4. }
  5. return super.cancel(mayInterruptIfRunning);
  6. }
  7. };

代码示例来源:origin: square/retrofit

  1. @Override public boolean cancel(boolean mayInterruptIfRunning) {
  2. if (mayInterruptIfRunning) {
  3. call.cancel();
  4. }
  5. return super.cancel(mayInterruptIfRunning);
  6. }
  7. };

代码示例来源:origin: resilience4j/resilience4j

  1. @Override
  2. public void cancel() {
  3. call.cancel();
  4. }

代码示例来源:origin: com.squareup.retrofit2/retrofit

  1. @Override public void cancel() {
  2. delegate.cancel();
  3. }

代码示例来源:origin: square/retrofit

  1. @Override public void cancel() {
  2. getDelegate().cancel();
  3. }

代码示例来源:origin: com.squareup.retrofit2/retrofit

  1. @Override public boolean cancel(boolean mayInterruptIfRunning) {
  2. if (mayInterruptIfRunning) {
  3. call.cancel();
  4. }
  5. return super.cancel(mayInterruptIfRunning);
  6. }
  7. };

代码示例来源:origin: com.squareup.retrofit2/retrofit

  1. @Override public boolean cancel(boolean mayInterruptIfRunning) {
  2. if (mayInterruptIfRunning) {
  3. call.cancel();
  4. }
  5. return super.cancel(mayInterruptIfRunning);
  6. }
  7. };

代码示例来源:origin: commonsguy/cw-omnibus

  1. @Override
  2. public void onDestroy() {
  3. if (call!=null) {
  4. call.cancel();
  5. }
  6. super.onDestroy();
  7. }

代码示例来源:origin: nickbutcher/plaid

  1. @Override
  2. public void onFiltersChanged(Source changedFilter) {
  3. if (changedFilter.active) {
  4. loadSource(changedFilter);
  5. } else { // filter deactivated
  6. final String key = changedFilter.key;
  7. if (inflightCalls.containsKey(key)) {
  8. final Call call = inflightCalls.get(key);
  9. if (call != null) call.cancel();
  10. inflightCalls.remove(key);
  11. }
  12. loadStoriesUseCase.cancelRequestOfSource(key);
  13. searchStoriesUseCase.cancelRequestOfSource(key);
  14. // clear the page index for the source
  15. pageIndexes.put(key, 0);
  16. }
  17. }
  18. };

代码示例来源:origin: nickbutcher/plaid

  1. public void cancelLoading() {
  2. if (inflightCalls.size() > 0) {
  3. for (Call call : inflightCalls.values()) {
  4. call.cancel();
  5. }
  6. inflightCalls.clear();
  7. }
  8. shotsRepository.cancelAllSearches();
  9. loadStoriesUseCase.cancelAllRequests();
  10. searchStoriesUseCase.cancelAllRequests();
  11. productHuntRepository.cancelAllRequests();
  12. }

代码示例来源:origin: resilience4j/resilience4j

  1. @Test
  2. public void passThroughCallsToDecoratedObject() throws IOException {
  3. final Call<String> call = mock(StringCall.class);
  4. final Call<String> decorated = new DecoratedCall<>(call);
  5. decorated.cancel();
  6. Mockito.verify(call).cancel();
  7. decorated.enqueue(null);
  8. Mockito.verify(call).enqueue(any());
  9. decorated.isExecuted();
  10. Mockito.verify(call).isExecuted();
  11. decorated.isCanceled();
  12. Mockito.verify(call).isCanceled();
  13. decorated.clone();
  14. Mockito.verify(call).clone();
  15. decorated.request();
  16. Mockito.verify(call).request();
  17. decorated.execute();
  18. Mockito.verify(call).execute();
  19. }

相关文章