package yh;

import android.util.Log;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.WeakHashMap;

/* loaded from: classes4.dex */
public class t {

    /* renamed from: a, reason: collision with root package name */
    private final Set f52768a = Collections.newSetFromMap(new WeakHashMap());

    /* renamed from: b, reason: collision with root package name */
    private final Set f52769b = new HashSet();

    /* renamed from: c, reason: collision with root package name */
    private boolean f52770c;

    public boolean a(com.bumptech.glide.request.c cVar) {
        boolean z10 = true;
        if (cVar == null) {
            return true;
        }
        boolean remove = this.f52768a.remove(cVar);
        if (!this.f52769b.remove(cVar) && !remove) {
            z10 = false;
        }
        if (z10) {
            cVar.clear();
        }
        return z10;
    }

    public void b() {
        Iterator it = ei.l.i(this.f52768a).iterator();
        while (it.hasNext()) {
            a((com.bumptech.glide.request.c) it.next());
        }
        this.f52769b.clear();
    }

    public void c() {
        this.f52770c = true;
        for (com.bumptech.glide.request.c cVar : ei.l.i(this.f52768a)) {
            if (cVar.isRunning() || cVar.i()) {
                cVar.clear();
                this.f52769b.add(cVar);
            }
        }
    }

    public void d() {
        this.f52770c = true;
        for (com.bumptech.glide.request.c cVar : ei.l.i(this.f52768a)) {
            if (cVar.isRunning()) {
                cVar.pause();
                this.f52769b.add(cVar);
            }
        }
    }

    public void e() {
        for (com.bumptech.glide.request.c cVar : ei.l.i(this.f52768a)) {
            if (!cVar.i() && !cVar.f()) {
                cVar.clear();
                if (this.f52770c) {
                    this.f52769b.add(cVar);
                } else {
                    cVar.h();
                }
            }
        }
    }

    public void f() {
        this.f52770c = false;
        for (com.bumptech.glide.request.c cVar : ei.l.i(this.f52768a)) {
            if (!cVar.i() && !cVar.isRunning()) {
                cVar.h();
            }
        }
        this.f52769b.clear();
    }

    public void g(com.bumptech.glide.request.c cVar) {
        this.f52768a.add(cVar);
        if (!this.f52770c) {
            cVar.h();
            return;
        }
        cVar.clear();
        if (Log.isLoggable("RequestTracker", 2)) {
            Log.v("RequestTracker", "Paused, delaying request");
        }
        this.f52769b.add(cVar);
    }

    public String toString() {
        return super.toString() + "{numRequests=" + this.f52768a.size() + ", isPaused=" + this.f52770c + "}";
    }
}
