package androidx.activity;

import android.os.Looper;
import android.os.SystemClock;
import android.view.View;
import android.view.ViewTreeObserver;

/* JADX INFO: loaded from: classes.dex */
public final class m implements k, ViewTreeObserver.OnDrawListener, Runnable {

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ ComponentActivity f490d;

    public m(ComponentActivity componentActivity) {
        this.f490d = componentActivity;
    }

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

    @Override // java.util.concurrent.Executor
    public final void execute(Runnable runnable) {
        nb.g.i(runnable, "runnable");
        this.f488b = runnable;
        View decorView = this.f490d.getWindow().getDecorView();
        nb.g.h(decorView, "window.decorView");
        if (!this.f489c) {
            decorView.postOnAnimation(new l(this, 0));
        } else if (nb.g.c(Looper.myLooper(), Looper.getMainLooper())) {
            decorView.invalidate();
        } else {
            decorView.postInvalidate();
        }
    }

    @Override // android.view.ViewTreeObserver.OnDrawListener
    public final void onDraw() {
        boolean z10;
        Runnable runnable = this.f488b;
        if (runnable == null) {
            if (SystemClock.uptimeMillis() > this.f487a) {
                this.f489c = false;
                this.f490d.getWindow().getDecorView().post(this);
                return;
            }
            return;
        }
        runnable.run();
        this.f488b = null;
        s fullyDrawnReporter = this.f490d.getFullyDrawnReporter();
        synchronized (fullyDrawnReporter.f535b) {
            z10 = fullyDrawnReporter.f536c;
        }
        if (z10) {
            this.f489c = false;
            this.f490d.getWindow().getDecorView().post(this);
        }
    }

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