package X6FRs_4.XnFJ5_9.KQgRr5e_0;

import android.view.View;
import android.view.ViewTreeObserver;
/* compiled from: OneShotPreDrawListener.java */
/* loaded from: classes.dex */
public class EuDEkJe_12 implements ViewTreeObserver.OnPreDrawListener, View.OnAttachStateChangeListener {
    public final View KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public ViewTreeObserver f1258KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final Runnable f1259KQgRr5e_0;

    public EuDEkJe_12(View view, Runnable runnable) {
        this.KQgRr5e_0 = view;
        this.f1258KQgRr5e_0 = view.getViewTreeObserver();
        this.f1259KQgRr5e_0 = runnable;
    }

    public static EuDEkJe_12 KQgRr5e_0(View view, Runnable runnable) {
        EuDEkJe_12 euDEkJe_12 = new EuDEkJe_12(view, runnable);
        view.getViewTreeObserver().addOnPreDrawListener(euDEkJe_12);
        view.addOnAttachStateChangeListener(euDEkJe_12);
        return euDEkJe_12;
    }

    @Override // android.view.ViewTreeObserver.OnPreDrawListener
    public boolean onPreDraw() {
        KQgRr5e_0();
        this.f1259KQgRr5e_0.run();
        return true;
    }

    @Override // android.view.View.OnAttachStateChangeListener
    public void onViewAttachedToWindow(View view) {
        this.f1258KQgRr5e_0 = view.getViewTreeObserver();
    }

    @Override // android.view.View.OnAttachStateChangeListener
    public void onViewDetachedFromWindow(View view) {
        KQgRr5e_0();
    }

    public void KQgRr5e_0() {
        if (this.f1258KQgRr5e_0.isAlive()) {
            this.f1258KQgRr5e_0.removeOnPreDrawListener(this);
        } else {
            this.KQgRr5e_0.getViewTreeObserver().removeOnPreDrawListener(this);
        }
        this.KQgRr5e_0.removeOnAttachStateChangeListener(this);
    }
}
