package d;

import android.os.Looper;
import android.os.SystemClock;
import android.view.View;
import android.view.ViewTreeObserver;
import androidx.fragment.app.N;
import androidx.lifecycle.G;
import r4.AbstractC0983h;

/* JADX INFO: renamed from: d.i, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class ViewTreeObserverOnDrawListenerC0515i implements InterfaceExecutorC0514h, ViewTreeObserver.OnDrawListener, Runnable {

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final long f5976k = SystemClock.uptimeMillis() + ((long) 10000);

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public Runnable f5977l;

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final /* synthetic */ N f5979n;

    public ViewTreeObserverOnDrawListenerC0515i(N n5) {
        this.f5979n = n5;
    }

    public final void a(View view) {
        if (this.f5978m) {
            return;
        }
        this.f5978m = true;
        view.getViewTreeObserver().addOnDrawListener(this);
    }

    @Override // java.util.concurrent.Executor
    public final void execute(Runnable runnable) {
        AbstractC0983h.e("runnable", runnable);
        this.f5977l = runnable;
        View decorView = this.f5979n.getWindow().getDecorView();
        AbstractC0983h.d("getDecorView(...)", decorView);
        if (!this.f5978m) {
            decorView.postOnAnimation(new G(5, this));
        } else if (AbstractC0983h.a(Looper.myLooper(), Looper.getMainLooper())) {
            decorView.invalidate();
        } else {
            decorView.postInvalidate();
        }
    }

    @Override // android.view.ViewTreeObserver.OnDrawListener
    public final void onDraw() {
        boolean z5;
        Runnable runnable = this.f5977l;
        if (runnable == null) {
            if (SystemClock.uptimeMillis() > this.f5976k) {
                this.f5978m = false;
                this.f5979n.getWindow().getDecorView().post(this);
                return;
            }
            return;
        }
        runnable.run();
        this.f5977l = null;
        C0521o fullyDrawnReporter = this.f5979n.getFullyDrawnReporter();
        synchronized (fullyDrawnReporter.f5992b) {
            z5 = fullyDrawnReporter.f5993c;
        }
        if (z5) {
            this.f5978m = false;
            this.f5979n.getWindow().getDecorView().post(this);
        }
    }

    @Override // java.lang.Runnable
    public final void run() {
        this.f5979n.getWindow().getDecorView().getViewTreeObserver().removeOnDrawListener(this);
    }
}
