package h.a.i1;

import android.os.Handler;
import android.os.Looper;
import g.e0.f;
import g.h0.c.l;
import g.i;
import h.a.c0;
import h.a.r0;
import h.a.x;
import h.a.x0;
import java.util.concurrent.CancellationException;

/* JADX INFO: compiled from: HandlerDispatcher.kt */
/* JADX INFO: loaded from: classes.dex */
@i
public final class a extends b implements x {
    private volatile a _immediate;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final Handler f4232e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final String f4233f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final boolean f4234g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final a f4235h;

    public a(Handler handler, String str, boolean z) {
        super(null);
        this.f4232e = handler;
        this.f4233f = str;
        this.f4234g = z;
        this._immediate = z ? this : null;
        a aVar = this._immediate;
        if (aVar == null) {
            aVar = new a(handler, str, true);
            this._immediate = aVar;
        }
        this.f4235h = aVar;
    }

    @Override // h.a.q
    public void e(f fVar, Runnable runnable) {
        if (this.f4232e.post(runnable)) {
            return;
        }
        CancellationException cancellationException = new CancellationException("The task was rejected, the handler underlying the dispatcher '" + this + "' was closed");
        int i2 = r0.f4326d;
        r0 r0Var = (r0) fVar.get(r0.a.f4327b);
        if (r0Var != null) {
            r0Var.o(cancellationException);
        }
        c0.a.e(fVar, runnable);
    }

    public boolean equals(Object obj) {
        return (obj instanceof a) && ((a) obj).f4232e == this.f4232e;
    }

    public int hashCode() {
        return System.identityHashCode(this.f4232e);
    }

    @Override // h.a.q
    public boolean q(f fVar) {
        return (this.f4234g && l.a(Looper.myLooper(), this.f4232e.getLooper())) ? false : true;
    }

    @Override // h.a.x0
    public x0 t() {
        return this.f4235h;
    }

    @Override // h.a.x0, h.a.q
    public String toString() {
        String strV = v();
        if (strV != null) {
            return strV;
        }
        String string = this.f4233f;
        if (string == null) {
            string = this.f4232e.toString();
        }
        return this.f4234g ? l.k(string, ".immediate") : string;
    }
}
