package q5;

import androidx.annotation.Nullable;
import com.bumptech.glide.request.RequestCoordinator$RequestState;

/* JADX INFO: loaded from: classes.dex */
public final class b implements d, c {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public volatile c f32202b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public volatile c f32203c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public RequestCoordinator$RequestState f32204d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public RequestCoordinator$RequestState f32205e;

    @Nullable
    private final d parent;

    public b(Object obj, @Nullable d dVar) {
        RequestCoordinator$RequestState requestCoordinator$RequestState = RequestCoordinator$RequestState.f5851c;
        this.f32204d = requestCoordinator$RequestState;
        this.f32205e = requestCoordinator$RequestState;
        this.f32201a = obj;
        this.parent = dVar;
    }

    @Override // q5.d, q5.c
    public final boolean a() {
        boolean z10;
        synchronized (this.f32201a) {
            try {
                z10 = this.f32202b.a() || this.f32203c.a();
            } finally {
            }
        }
        return z10;
    }

    @Override // q5.d
    public final boolean b(c cVar) {
        boolean z10;
        synchronized (this.f32201a) {
            d dVar = this.parent;
            z10 = (dVar == null || dVar.b(this)) && k(cVar);
        }
        return z10;
    }

    @Override // q5.d
    public final boolean c(c cVar) {
        boolean z10;
        synchronized (this.f32201a) {
            d dVar = this.parent;
            z10 = (dVar == null || dVar.c(this)) && k(cVar);
        }
        return z10;
    }

    @Override // q5.c
    public final void clear() {
        synchronized (this.f32201a) {
            try {
                RequestCoordinator$RequestState requestCoordinator$RequestState = RequestCoordinator$RequestState.f5851c;
                this.f32204d = requestCoordinator$RequestState;
                this.f32202b.clear();
                if (this.f32205e != requestCoordinator$RequestState) {
                    this.f32205e = requestCoordinator$RequestState;
                    this.f32203c.clear();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // q5.d
    public final boolean d(c cVar) {
        boolean z10;
        synchronized (this.f32201a) {
            d dVar = this.parent;
            z10 = (dVar == null || dVar.d(this)) && k(cVar);
        }
        return z10;
    }

    @Override // q5.d
    public final void e(c cVar) {
        synchronized (this.f32201a) {
            try {
                if (cVar.equals(this.f32203c)) {
                    this.f32205e = RequestCoordinator$RequestState.f5853e;
                    d dVar = this.parent;
                    if (dVar != null) {
                        dVar.e(this);
                    }
                    return;
                }
                this.f32204d = RequestCoordinator$RequestState.f5853e;
                RequestCoordinator$RequestState requestCoordinator$RequestState = this.f32205e;
                RequestCoordinator$RequestState requestCoordinator$RequestState2 = RequestCoordinator$RequestState.f5849a;
                if (requestCoordinator$RequestState != requestCoordinator$RequestState2) {
                    this.f32205e = requestCoordinator$RequestState2;
                    this.f32203c.i();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // q5.c
    public final boolean f(c cVar) {
        if (!(cVar instanceof b)) {
            return false;
        }
        b bVar = (b) cVar;
        return this.f32202b.f(bVar.f32202b) && this.f32203c.f(bVar.f32203c);
    }

    @Override // q5.c
    public final boolean g() {
        boolean z10;
        synchronized (this.f32201a) {
            try {
                RequestCoordinator$RequestState requestCoordinator$RequestState = this.f32204d;
                RequestCoordinator$RequestState requestCoordinator$RequestState2 = RequestCoordinator$RequestState.f5851c;
                z10 = requestCoordinator$RequestState == requestCoordinator$RequestState2 && this.f32205e == requestCoordinator$RequestState2;
            } finally {
            }
        }
        return z10;
    }

    @Override // q5.d
    public final d getRoot() {
        d root;
        synchronized (this.f32201a) {
            try {
                d dVar = this.parent;
                root = dVar != null ? dVar.getRoot() : this;
            } catch (Throwable th) {
                throw th;
            }
        }
        return root;
    }

    @Override // q5.d
    public final void h(c cVar) {
        synchronized (this.f32201a) {
            try {
                if (cVar.equals(this.f32202b)) {
                    this.f32204d = RequestCoordinator$RequestState.f5852d;
                } else if (cVar.equals(this.f32203c)) {
                    this.f32205e = RequestCoordinator$RequestState.f5852d;
                }
                d dVar = this.parent;
                if (dVar != null) {
                    dVar.h(this);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // q5.c
    public final void i() {
        synchronized (this.f32201a) {
            try {
                RequestCoordinator$RequestState requestCoordinator$RequestState = this.f32204d;
                RequestCoordinator$RequestState requestCoordinator$RequestState2 = RequestCoordinator$RequestState.f5849a;
                if (requestCoordinator$RequestState != requestCoordinator$RequestState2) {
                    this.f32204d = requestCoordinator$RequestState2;
                    this.f32202b.i();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // q5.c
    public final boolean isRunning() {
        boolean z10;
        synchronized (this.f32201a) {
            try {
                RequestCoordinator$RequestState requestCoordinator$RequestState = this.f32204d;
                RequestCoordinator$RequestState requestCoordinator$RequestState2 = RequestCoordinator$RequestState.f5849a;
                z10 = requestCoordinator$RequestState == requestCoordinator$RequestState2 || this.f32205e == requestCoordinator$RequestState2;
            } finally {
            }
        }
        return z10;
    }

    @Override // q5.c
    public final boolean j() {
        boolean z10;
        synchronized (this.f32201a) {
            try {
                RequestCoordinator$RequestState requestCoordinator$RequestState = this.f32204d;
                RequestCoordinator$RequestState requestCoordinator$RequestState2 = RequestCoordinator$RequestState.f5852d;
                z10 = requestCoordinator$RequestState == requestCoordinator$RequestState2 || this.f32205e == requestCoordinator$RequestState2;
            } finally {
            }
        }
        return z10;
    }

    public final boolean k(c cVar) {
        return cVar.equals(this.f32202b) || (this.f32204d == RequestCoordinator$RequestState.f5853e && cVar.equals(this.f32203c));
    }

    @Override // q5.c
    public final void pause() {
        synchronized (this.f32201a) {
            try {
                RequestCoordinator$RequestState requestCoordinator$RequestState = this.f32204d;
                RequestCoordinator$RequestState requestCoordinator$RequestState2 = RequestCoordinator$RequestState.f5849a;
                if (requestCoordinator$RequestState == requestCoordinator$RequestState2) {
                    this.f32204d = RequestCoordinator$RequestState.f5850b;
                    this.f32202b.pause();
                }
                if (this.f32205e == requestCoordinator$RequestState2) {
                    this.f32205e = RequestCoordinator$RequestState.f5850b;
                    this.f32203c.pause();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }
}
