本文整理了Java中retrofit2.Call.isExecuted()
方法的一些代码示例,展示了Call.isExecuted()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Call.isExecuted()
方法的具体详情如下:
包路径:retrofit2.Call
类名称:Call
方法名:isExecuted
[英]Returns true if this call has been either #execute() or #enqueue(Callback). It is an error to execute or enqueue a call more than once.
[中]如果此调用是#execute()或#enqueue(回调),则返回true。多次执行或排队调用是错误的。
代码示例来源:origin: square/retrofit
@Override public boolean isExecuted() {
return delegate.isExecuted();
}
代码示例来源:origin: resilience4j/resilience4j
@Override
public boolean isExecuted() {
return call.isExecuted();
}
代码示例来源:origin: com.squareup.retrofit2/retrofit
@Override public boolean isExecuted() {
return delegate.isExecuted();
}
代码示例来源:origin: square/retrofit
@Override public boolean isExecuted() {
return getDelegate().isExecuted();
}
代码示例来源: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();
}
代码示例来源:origin: palantir/conjure-java-runtime
@Override
public boolean isExecuted() {
return delegate.isExecuted();
}
代码示例来源:origin: NightlyNexus/logging-retrofit
@Override public boolean isExecuted() {
return delegate.isExecuted();
}
代码示例来源:origin: iagocanalejas/retrocache
@Override
public boolean isExecuted() {
return mCall.isExecuted() || mExecuted;
}
代码示例来源:origin: iagocanalejas/retrocache
@Override
public void refresh(final Callback<T> callback) {
if (callback == null) {
throw new NullPointerException("callback == null");
}
if (mExecuted || mCall.isExecuted()) {
throw new IllegalStateException("Already executed.");
}
mExecuted = true;
if (mCachingActive) {
new Thread(new Runnable() {
@Override
public void run() {
networkLoad(callback, true);
}
}).start();
return;
}
delegate(callback);
}
代码示例来源:origin: iagocanalejas/retrocache
CachedCall(Executor executor, Call<T> call, Type responseType, Annotation[] annotations, Retrofit retrofit, Cache<String, byte[]> cachingSystem) {
this.mExecutor = executor;
this.mCall = call;
this.mResponseType = responseType;
this.mAnnotations = annotations;
this.mRetrofit = retrofit;
this.mCachingSystem = cachingSystem;
this.mRequest = RequestBuilder.build(call);
mCachingActive = mRequest != null && mRequest.method().equals("GET");
mExecuted = mCall.isExecuted();
mCanceled = mCall.isCanceled();
}
代码示例来源:origin: iagocanalejas/retrocache
@Override
public void enqueue(final Callback<T> callback) {
if (callback == null) {
throw new NullPointerException("callback == null");
}
if (mExecuted || mCall.isExecuted()) {
throw new IllegalStateException("Already executed.");
}
mExecuted = true;
if (mCachingActive) {
// Look in cache if we are in a GET method
new Thread(new Runnable() {
@Override
public void run() {
if (!cacheLoad(callback)) {
networkLoad(callback, false);
}
}
}).start();
return;
}
delegate(callback);
}
代码示例来源:origin: byhieg/easyweather
if (requestCall.isExecuted()) {
call = requestCall.clone();
} else {
代码示例来源:origin: byhieg/easyweather
public <T> T syncRequest(final Call<T> requestCall) {
Call<T> call;
if (requestCall.isExecuted()) {
call = requestCall.clone();
} else {
call = requestCall;
}
try{
Response<T> response = call.execute();
if (response.isSuccessful()) {
T result = response.body();
return result;
}else {
return null;
}
} catch (IOException e) {
Logger.e(e.getMessage());
}
return null;
}
//
代码示例来源:origin: iagocanalejas/retrocache
@Override
public Response<T> execute() throws IOException {
if (mExecuted || mCall.isExecuted()) {
throw new IllegalStateException("Already executed.");
}
mExecuted = true;
if (mCachingActive) {
byte[] data = mCachingSystem.get(CacheUtils.urlToKey(mCall.request().url()));
if (data == null) { // Response is not cached
Response<T> response = mCall.execute();
if (response.isSuccessful()) {
mCachingSystem.put(
CacheUtils.urlToKey(mCall.request().url()),
CacheUtils.responseToBytes(mRetrofit, response.body(),
responseType(), mAnnotations));
}
return response;
}
// Response is cached
final T convertedData = CacheUtils.bytesToResponse(
mRetrofit, mResponseType, mAnnotations, data);
return Response.success(convertedData);
}
return mCall.execute();
}
代码示例来源:origin: byhieg/easyweather
if (requestCall.isExecuted()) {
call = requestCall.clone();
} else {
内容来源于网络,如有侵权,请联系作者删除!