package q5;

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public boolean f32211f;

    @Nullable
    private final d parent;

    public h(Object obj, @Nullable d dVar) {
        RequestCoordinator$RequestState requestCoordinator$RequestState = RequestCoordinator$RequestState.f5851c;
        this.f32209d = requestCoordinator$RequestState;
        this.f32210e = requestCoordinator$RequestState;
        this.f32206a = obj;
        this.parent = dVar;
    }

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

    @Override // q5.d
    public final boolean b(c cVar) {
        boolean z10;
        synchronized (this.f32206a) {
            try {
                d dVar = this.parent;
                z10 = (dVar == null || dVar.b(this)) && cVar.equals(this.f32207b) && !a();
            } finally {
            }
        }
        return z10;
    }

    @Override // q5.d
    public final boolean c(c cVar) {
        boolean z10;
        synchronized (this.f32206a) {
            try {
                d dVar = this.parent;
                z10 = (dVar == null || dVar.c(this)) && (cVar.equals(this.f32207b) || this.f32209d != RequestCoordinator$RequestState.f5852d);
            } finally {
            }
        }
        return z10;
    }

    @Override // q5.c
    public final void clear() {
        synchronized (this.f32206a) {
            this.f32211f = false;
            RequestCoordinator$RequestState requestCoordinator$RequestState = RequestCoordinator$RequestState.f5851c;
            this.f32209d = requestCoordinator$RequestState;
            this.f32210e = requestCoordinator$RequestState;
            this.f32208c.clear();
            this.f32207b.clear();
        }
    }

    @Override // q5.d
    public final boolean d(c cVar) {
        boolean z10;
        synchronized (this.f32206a) {
            try {
                d dVar = this.parent;
                z10 = (dVar == null || dVar.d(this)) && cVar.equals(this.f32207b) && this.f32209d != RequestCoordinator$RequestState.f5850b;
            } finally {
            }
        }
        return z10;
    }

    @Override // q5.d
    public final void e(c cVar) {
        synchronized (this.f32206a) {
            try {
                if (!cVar.equals(this.f32207b)) {
                    this.f32210e = RequestCoordinator$RequestState.f5853e;
                    return;
                }
                this.f32209d = RequestCoordinator$RequestState.f5853e;
                d dVar = this.parent;
                if (dVar != null) {
                    dVar.e(this);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // q5.c
    public final boolean f(c cVar) {
        if (!(cVar instanceof h)) {
            return false;
        }
        h hVar = (h) cVar;
        if (this.f32207b == null) {
            if (hVar.f32207b != null) {
                return false;
            }
        } else if (!this.f32207b.f(hVar.f32207b)) {
            return false;
        }
        if (this.f32208c == null) {
            if (hVar.f32208c != null) {
                return false;
            }
        } else if (!this.f32208c.f(hVar.f32208c)) {
            return false;
        }
        return true;
    }

    @Override // q5.c
    public final boolean g() {
        boolean z10;
        synchronized (this.f32206a) {
            z10 = this.f32209d == RequestCoordinator$RequestState.f5851c;
        }
        return z10;
    }

    @Override // q5.d
    public final d getRoot() {
        d root;
        synchronized (this.f32206a) {
            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.f32206a) {
            try {
                if (cVar.equals(this.f32208c)) {
                    this.f32210e = RequestCoordinator$RequestState.f5852d;
                    return;
                }
                this.f32209d = RequestCoordinator$RequestState.f5852d;
                d dVar = this.parent;
                if (dVar != null) {
                    dVar.h(this);
                }
                if (!this.f32210e.a()) {
                    this.f32208c.clear();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // q5.c
    public final void i() {
        synchronized (this.f32206a) {
            try {
                this.f32211f = true;
                try {
                    if (this.f32209d != RequestCoordinator$RequestState.f5852d) {
                        RequestCoordinator$RequestState requestCoordinator$RequestState = this.f32210e;
                        RequestCoordinator$RequestState requestCoordinator$RequestState2 = RequestCoordinator$RequestState.f5849a;
                        if (requestCoordinator$RequestState != requestCoordinator$RequestState2) {
                            this.f32210e = requestCoordinator$RequestState2;
                            this.f32208c.i();
                        }
                    }
                    if (this.f32211f) {
                        RequestCoordinator$RequestState requestCoordinator$RequestState3 = this.f32209d;
                        RequestCoordinator$RequestState requestCoordinator$RequestState4 = RequestCoordinator$RequestState.f5849a;
                        if (requestCoordinator$RequestState3 != requestCoordinator$RequestState4) {
                            this.f32209d = requestCoordinator$RequestState4;
                            this.f32207b.i();
                        }
                    }
                    this.f32211f = false;
                } catch (Throwable th) {
                    this.f32211f = false;
                    throw th;
                }
            } catch (Throwable th2) {
                throw th2;
            }
        }
    }

    @Override // q5.c
    public final boolean isRunning() {
        boolean z10;
        synchronized (this.f32206a) {
            z10 = this.f32209d == RequestCoordinator$RequestState.f5849a;
        }
        return z10;
    }

    @Override // q5.c
    public final boolean j() {
        boolean z10;
        synchronized (this.f32206a) {
            z10 = this.f32209d == RequestCoordinator$RequestState.f5852d;
        }
        return z10;
    }

    @Override // q5.c
    public final void pause() {
        synchronized (this.f32206a) {
            try {
                if (!this.f32210e.a()) {
                    this.f32210e = RequestCoordinator$RequestState.f5850b;
                    this.f32208c.pause();
                }
                if (!this.f32209d.a()) {
                    this.f32209d = RequestCoordinator$RequestState.f5850b;
                    this.f32207b.pause();
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }
}
