package o;

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

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class K5 implements Choreographer.FrameCallback, Runnable {
    public final /* synthetic */ L5 l;

    public K5(L5 l5) {
        this.l = l5;
    }

    @Override // android.view.Choreographer.FrameCallback
    public final void doFrame(long j) {
        this.l.n.removeCallbacks(this);
        L5.X(this.l);
        L5 l5 = this.l;
        synchronized (l5.f205o) {
            if (l5.t) {
                l5.t = false;
                ArrayList arrayList = l5.q;
                l5.q = l5.r;
                l5.r = arrayList;
                int size = arrayList.size();
                for (int i = 0; i < size; i++) {
                    ((Choreographer.FrameCallback) arrayList.get(i)).doFrame(j);
                }
                arrayList.clear();
            }
        }
    }

    @Override // java.lang.Runnable
    public final void run() {
        L5.X(this.l);
        L5 l5 = this.l;
        synchronized (l5.f205o) {
            if (l5.q.isEmpty()) {
                l5.m.removeFrameCallback(this);
                l5.t = false;
            }
        }
    }
}
