package o;

import android.os.Handler;
import android.view.Choreographer;
import java.util.ArrayList;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class L5 extends AbstractC2842wn {
    public static final C1014dc0 w = new C1014dc0(G3.v);
    public static final J5 x = new J5(0);
    public final Choreographer m;
    public final Handler n;
    public boolean s;
    public boolean t;
    public final N5 v;

    /* renamed from: o, reason: collision with root package name */
    public final Object f205o = new Object();
    public final C1172f9 p = new C1172f9();
    public ArrayList q = new ArrayList();
    public ArrayList r = new ArrayList();
    public final K5 u = new K5(this);

    public L5(Choreographer choreographer, Handler handler) {
        this.m = choreographer;
        this.n = handler;
        this.v = new N5(choreographer, this);
    }

    public static final void X(L5 l5) {
        Runnable runnable;
        boolean z;
        do {
            synchronized (l5.f205o) {
                C1172f9 c1172f9 = l5.p;
                runnable = (Runnable) (c1172f9.isEmpty() ? null : c1172f9.removeFirst());
            }
            while (runnable != null) {
                runnable.run();
                synchronized (l5.f205o) {
                    C1172f9 c1172f92 = l5.p;
                    runnable = (Runnable) (c1172f92.isEmpty() ? null : c1172f92.removeFirst());
                }
            }
            synchronized (l5.f205o) {
                if (l5.p.isEmpty()) {
                    z = false;
                    l5.s = false;
                } else {
                    z = true;
                }
            }
        } while (z);
    }

    @Override // o.AbstractC2842wn
    public final void T(InterfaceC2747vn interfaceC2747vn, Runnable runnable) {
        synchronized (this.f205o) {
            this.p.addLast(runnable);
            if (!this.s) {
                this.s = true;
                this.n.post(this.u);
                if (!this.t) {
                    this.t = true;
                    this.m.postFrameCallback(this.u);
                }
            }
        }
    }
}
