package retrofit2; import e3.I; import java.io.IOException; import java.lang.annotation.Annotation; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.Objects; import java.util.concurrent.Executor; import r3.K; import retrofit2.CallAdapter; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public final class DefaultCallAdapterFactory extends CallAdapter.Factory { private final Executor callbackExecutor; /* renamed from: retrofit2.DefaultCallAdapterFactory$1 */ /* loaded from: classes3.dex */ public class AnonymousClass1 implements CallAdapter> { final /* synthetic */ Executor val$executor; final /* synthetic */ Type val$responseType; public AnonymousClass1(Type type, Executor executor) { r2 = type; r3 = executor; } @Override // retrofit2.CallAdapter public Type responseType() { return r2; } @Override // retrofit2.CallAdapter public Call adapt(Call call) { Executor executor = r3; return executor == null ? call : new ExecutorCallbackCall(executor, call); } } /* loaded from: classes3.dex */ public static final class ExecutorCallbackCall implements Call { final Executor callbackExecutor; final Call delegate; /* renamed from: retrofit2.DefaultCallAdapterFactory$ExecutorCallbackCall$1 */ /* loaded from: classes3.dex */ public class AnonymousClass1 implements Callback { final /* synthetic */ Callback val$callback; public AnonymousClass1(Callback callback) { this.val$callback = callback; } public /* synthetic */ void lambda$onFailure$1(Callback callback, Throwable th) { callback.onFailure(ExecutorCallbackCall.this, th); } public /* synthetic */ void lambda$onResponse$0(Callback callback, Response response) { if (ExecutorCallbackCall.this.delegate.isCanceled()) { callback.onFailure(ExecutorCallbackCall.this, new IOException("Canceled")); } else { callback.onResponse(ExecutorCallbackCall.this, response); } } @Override // retrofit2.Callback public void onFailure(Call call, Throwable th) { ExecutorCallbackCall.this.callbackExecutor.execute(new a(this, this.val$callback, th, 1)); } @Override // retrofit2.Callback public void onResponse(Call call, Response response) { ExecutorCallbackCall.this.callbackExecutor.execute(new a(this, this.val$callback, response, 0)); } } public ExecutorCallbackCall(Executor executor, Call call) { this.callbackExecutor = executor; this.delegate = call; } @Override // retrofit2.Call public void cancel() { this.delegate.cancel(); } @Override // retrofit2.Call public void enqueue(Callback callback) { Objects.requireNonNull(callback, "callback == null"); this.delegate.enqueue(new AnonymousClass1(callback)); } @Override // retrofit2.Call public Response execute() throws IOException { return this.delegate.execute(); } @Override // retrofit2.Call public boolean isCanceled() { return this.delegate.isCanceled(); } @Override // retrofit2.Call public boolean isExecuted() { return this.delegate.isExecuted(); } @Override // retrofit2.Call public I request() { return this.delegate.request(); } @Override // retrofit2.Call public K timeout() { return this.delegate.timeout(); } @Override // retrofit2.Call public Call clone() { return new ExecutorCallbackCall(this.callbackExecutor, this.delegate.clone()); } } public DefaultCallAdapterFactory(Executor executor) { this.callbackExecutor = executor; } @Override // retrofit2.CallAdapter.Factory public CallAdapter get(Type type, Annotation[] annotationArr, Retrofit retrofit) { if (CallAdapter.Factory.getRawType(type) != Call.class) { return null; } if (type instanceof ParameterizedType) { return new CallAdapter>() { // from class: retrofit2.DefaultCallAdapterFactory.1 final /* synthetic */ Executor val$executor; final /* synthetic */ Type val$responseType; public AnonymousClass1(Type type2, Executor executor) { r2 = type2; r3 = executor; } @Override // retrofit2.CallAdapter public Type responseType() { return r2; } @Override // retrofit2.CallAdapter public Call adapt(Call call) { Executor executor = r3; return executor == null ? call : new ExecutorCallbackCall(executor, call); } }; } throw new IllegalArgumentException("Call return type must be parameterized as Call or Call"); } }