package j;

import j.c;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.concurrent.Executor;
import javax.annotation.Nullable;

/* JADX INFO: loaded from: classes.dex */
public final class k extends c.a {

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

    public class a implements c<Object, j.b<?>> {

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

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

        public a(k kVar, Type type, Executor executor) {
            this.f6930a = type;
            this.f6931b = executor;
        }

        @Override // j.c
        public Type a() {
            return this.f6930a;
        }

        @Override // j.c
        public j.b<?> b(j.b<Object> bVar) {
            Executor executor = this.f6931b;
            return executor == null ? bVar : new b(executor, bVar);
        }
    }

    public static final class b<T> implements j.b<T> {

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

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public final j.b<T> f6933c;

        public class a implements d<T> {

            /* JADX INFO: renamed from: a, reason: collision with root package name */
            public final /* synthetic */ d f6934a;

            /* JADX INFO: renamed from: j.k$b$a$a, reason: collision with other inner class name */
            public class RunnableC0096a implements Runnable {

                /* JADX INFO: renamed from: b, reason: collision with root package name */
                public final /* synthetic */ b0 f6936b;

                public RunnableC0096a(b0 b0Var) {
                    this.f6936b = b0Var;
                }

                @Override // java.lang.Runnable
                public void run() {
                    if (b.this.f6933c.E()) {
                        a aVar = a.this;
                        aVar.f6934a.b(b.this, new IOException("Canceled"));
                    } else {
                        a aVar2 = a.this;
                        aVar2.f6934a.a(b.this, this.f6936b);
                    }
                }
            }

            /* JADX INFO: renamed from: j.k$b$a$b, reason: collision with other inner class name */
            public class RunnableC0097b implements Runnable {

                /* JADX INFO: renamed from: b, reason: collision with root package name */
                public final /* synthetic */ Throwable f6938b;

                public RunnableC0097b(Throwable th) {
                    this.f6938b = th;
                }

                @Override // java.lang.Runnable
                public void run() {
                    a aVar = a.this;
                    aVar.f6934a.b(b.this, this.f6938b);
                }
            }

            public a(d dVar) {
                this.f6934a = dVar;
            }

            @Override // j.d
            public void a(j.b<T> bVar, b0<T> b0Var) {
                b.this.f6932b.execute(new RunnableC0096a(b0Var));
            }

            @Override // j.d
            public void b(j.b<T> bVar, Throwable th) {
                b.this.f6932b.execute(new RunnableC0097b(th));
            }
        }

        public b(Executor executor, j.b<T> bVar) {
            this.f6932b = executor;
            this.f6933c = bVar;
        }

        @Override // j.b
        public void B(d<T> dVar) {
            this.f6933c.B(new a(dVar));
        }

        @Override // j.b
        public boolean E() {
            return this.f6933c.E();
        }

        @Override // j.b
        public void a() {
            this.f6933c.a();
        }

        @Override // j.b
        /* JADX INFO: renamed from: i, reason: merged with bridge method [inline-methods] */
        public j.b<T> clone() {
            return new b(this.f6932b, this.f6933c.clone());
        }

        @Override // j.b
        public b0<T> o() {
            return this.f6933c.o();
        }

        @Override // j.b
        public g.z z() {
            return this.f6933c.z();
        }
    }

    public k(@Nullable Executor executor) {
        this.f6929a = executor;
    }

    @Override // j.c.a
    @Nullable
    public c<?, ?> a(Type type, Annotation[] annotationArr, d0 d0Var) {
        if (h0.f(type) != j.b.class) {
            return null;
        }
        if (type instanceof ParameterizedType) {
            return new a(this, h0.e(0, (ParameterizedType) type), h0.i(annotationArr, f0.class) ? null : this.f6929a);
        }
        throw new IllegalArgumentException("Call return type must be parameterized as Call<Foo> or Call<? extends Foo>");
    }
}
