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

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

本文整理了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

@Override protected void interruptTask() {
  call.cancel();
 }
};

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

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

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

@Override protected void interruptTask() {
  call.cancel();
 }
};

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

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

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

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

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

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

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

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

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

@Override public boolean cancel(boolean mayInterruptIfRunning) {
  if (mayInterruptIfRunning) {
   call.cancel();
  }
  return super.cancel(mayInterruptIfRunning);
 }
};

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

@Override public boolean cancel(boolean mayInterruptIfRunning) {
  if (mayInterruptIfRunning) {
   call.cancel();
  }
  return super.cancel(mayInterruptIfRunning);
 }
};

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

@Override public boolean cancel(boolean mayInterruptIfRunning) {
  if (mayInterruptIfRunning) {
   call.cancel();
  }
  return super.cancel(mayInterruptIfRunning);
 }
};

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

@Override public boolean cancel(boolean mayInterruptIfRunning) {
  if (mayInterruptIfRunning) {
   call.cancel();
  }
  return super.cancel(mayInterruptIfRunning);
 }
};

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

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

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

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

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

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

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

@Override public boolean cancel(boolean mayInterruptIfRunning) {
  if (mayInterruptIfRunning) {
   call.cancel();
  }
  return super.cancel(mayInterruptIfRunning);
 }
};

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

@Override public boolean cancel(boolean mayInterruptIfRunning) {
  if (mayInterruptIfRunning) {
   call.cancel();
  }
  return super.cancel(mayInterruptIfRunning);
 }
};

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

@Override
public void onDestroy() {
 if (call!=null) {
  call.cancel();
 }
 super.onDestroy();
}

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

@Override
  public void onFiltersChanged(Source changedFilter) {
    if (changedFilter.active) {
      loadSource(changedFilter);
    } else { // filter deactivated
      final String key = changedFilter.key;
      if (inflightCalls.containsKey(key)) {
        final Call call = inflightCalls.get(key);
        if (call != null) call.cancel();
        inflightCalls.remove(key);
      }
      loadStoriesUseCase.cancelRequestOfSource(key);
      searchStoriesUseCase.cancelRequestOfSource(key);
      // clear the page index for the source
      pageIndexes.put(key, 0);
    }
  }
};

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

public void cancelLoading() {
  if (inflightCalls.size() > 0) {
    for (Call call : inflightCalls.values()) {
      call.cancel();
    }
    inflightCalls.clear();
  }
  shotsRepository.cancelAllSearches();
  loadStoriesUseCase.cancelAllRequests();
  searchStoriesUseCase.cancelAllRequests();
  productHuntRepository.cancelAllRequests();
}

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

@Test
public void passThroughCallsToDecoratedObject() throws IOException {
  final Call<String> call = mock(StringCall.class);
  final Call<String> decorated = new DecoratedCall<>(call);
  decorated.cancel();
  Mockito.verify(call).cancel();
  decorated.enqueue(null);
  Mockito.verify(call).enqueue(any());
  decorated.isExecuted();
  Mockito.verify(call).isExecuted();
  decorated.isCanceled();
  Mockito.verify(call).isCanceled();
  decorated.clone();
  Mockito.verify(call).clone();
  decorated.request();
  Mockito.verify(call).request();
  decorated.execute();
  Mockito.verify(call).execute();
}

相关文章