package p023h0;

import android.view.View;
import android.view.ViewTreeObserver;

/* renamed from: h0.d1 */
/* loaded from: classes.dex */
public final class ViewTreeObserver$OnPreDrawListenerC0801d1 implements ViewTreeObserver.OnPreDrawListener, View.OnAttachStateChangeListener {

    /* renamed from: d */
    public final View f2426d;

    /* renamed from: e */
    public ViewTreeObserver f2427e;

    /* renamed from: f */
    public final Runnable f2428f;

    public ViewTreeObserver$OnPreDrawListenerC0801d1(View view, Runnable runnable) {
        this.f2426d = view;
        this.f2427e = view.getViewTreeObserver();
        this.f2428f = runnable;
    }

    /* renamed from: a */
    public static ViewTreeObserver$OnPreDrawListenerC0801d1 m2889a(View view, Runnable runnable) {
        if (view != null) {
            if (runnable != null) {
                ViewTreeObserver$OnPreDrawListenerC0801d1 viewTreeObserver$OnPreDrawListenerC0801d1 = new ViewTreeObserver$OnPreDrawListenerC0801d1(view, runnable);
                view.getViewTreeObserver().addOnPreDrawListener(viewTreeObserver$OnPreDrawListenerC0801d1);
                view.addOnAttachStateChangeListener(viewTreeObserver$OnPreDrawListenerC0801d1);
                return viewTreeObserver$OnPreDrawListenerC0801d1;
            }
            throw new NullPointerException("runnable == null");
        }
        throw new NullPointerException("view == null");
    }

    /* renamed from: b */
    public void m2888b() {
        (this.f2427e.isAlive() ? this.f2427e : this.f2426d.getViewTreeObserver()).removeOnPreDrawListener(this);
        this.f2426d.removeOnAttachStateChangeListener(this);
    }

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

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

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