package f;

import f.e;
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 javax.annotation.Nullable;
import okhttp3.Request;

/* JADX INFO: compiled from: DefaultCallAdapterFactory.java */
/* JADX INFO: loaded from: classes.dex */
final class i extends e.a {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    @Nullable
    private final Executor f1643a;

    /* JADX INFO: compiled from: DefaultCallAdapterFactory.java */
    class a implements e<Object, d<?>> {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        final /* synthetic */ Type f1644a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final /* synthetic */ Executor f1645b;

        a(i iVar, Type type, Executor executor) {
            this.f1644a = type;
            this.f1645b = executor;
        }

        @Override // f.e
        public Type a() {
            return this.f1644a;
        }

        @Override // f.e
        /* JADX INFO: renamed from: c, reason: merged with bridge method [inline-methods] */
        public d<Object> b(d<Object> dVar) {
            Executor executor = this.f1645b;
            return executor == null ? dVar : new b(executor, dVar);
        }
    }

    /* JADX INFO: compiled from: DefaultCallAdapterFactory.java */
    static final class b<T> implements d<T> {

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final Executor f1646b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        final d<T> f1647c;

        /* JADX INFO: compiled from: DefaultCallAdapterFactory.java */
        class a implements f<T> {

            /* JADX INFO: renamed from: b, reason: collision with root package name */
            final /* synthetic */ f f1648b;

            a(f fVar) {
                this.f1648b = fVar;
            }

            @Override // f.f
            public void a(d<T> dVar, final Throwable th) {
                Executor executor = b.this.f1646b;
                final f fVar = this.f1648b;
                executor.execute(new Runnable() { // from class: f.b
                    @Override // java.lang.Runnable
                    public final void run() {
                        this.f1627b.c(fVar, th);
                    }
                });
            }

            @Override // f.f
            public void b(d<T> dVar, final t<T> tVar) {
                Executor executor = b.this.f1646b;
                final f fVar = this.f1648b;
                executor.execute(new Runnable() { // from class: f.a
                    @Override // java.lang.Runnable
                    public final void run() {
                        this.f1617b.d(fVar, tVar);
                    }
                });
            }

            public /* synthetic */ void c(f fVar, Throwable th) {
                fVar.a(b.this, th);
            }

            public /* synthetic */ void d(f fVar, t tVar) {
                if (b.this.f1647c.isCanceled()) {
                    fVar.a(b.this, new IOException("Canceled"));
                } else {
                    fVar.b(b.this, tVar);
                }
            }
        }

        b(Executor executor, d<T> dVar) {
            this.f1646b = executor;
            this.f1647c = dVar;
        }

        @Override // f.d
        public void cancel() {
            this.f1647c.cancel();
        }

        @Override // f.d
        public t<T> execute() throws IOException {
            return this.f1647c.execute();
        }

        @Override // f.d
        public boolean isCanceled() {
            return this.f1647c.isCanceled();
        }

        @Override // f.d
        public Request request() {
            return this.f1647c.request();
        }

        @Override // f.d
        public void v(f<T> fVar) {
            Objects.requireNonNull(fVar, "callback == null");
            this.f1647c.v(new a(fVar));
        }

        @Override // f.d
        /* JADX INFO: renamed from: clone, reason: merged with bridge method [inline-methods] */
        public d<T> m5clone() {
            return new b(this.f1646b, this.f1647c.m5clone());
        }
    }

    i(@Nullable Executor executor) {
        this.f1643a = executor;
    }

    @Override // f.e.a
    @Nullable
    public e<?, ?> a(Type type, Annotation[] annotationArr, u uVar) {
        if (e.a.c(type) != d.class) {
            return null;
        }
        if (type instanceof ParameterizedType) {
            return new a(this, y.g(0, (ParameterizedType) type), y.l(annotationArr, w.class) ? null : this.f1643a);
        }
        throw new IllegalArgumentException("Call return type must be parameterized as Call<Foo> or Call<? extends Foo>");
    }
}
