55 lines
1.9 KiB
Java
55 lines
1.9 KiB
Java
|
package o;
|
||
|
|
||
|
import android.view.View;
|
||
|
import android.view.ViewTreeObserver;
|
||
|
|
||
|
/* renamed from: o.zYL, reason: case insensitive filesystem */
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class ViewTreeObserverOnPreDrawListenerC17759zYL implements ViewTreeObserver.OnPreDrawListener, View.OnAttachStateChangeListener {
|
||
|
private final Runnable c;
|
||
|
private ViewTreeObserver d;
|
||
|
private final View e;
|
||
|
|
||
|
private ViewTreeObserverOnPreDrawListenerC17759zYL(View view, Runnable runnable) {
|
||
|
this.e = view;
|
||
|
this.d = view.getViewTreeObserver();
|
||
|
this.c = runnable;
|
||
|
}
|
||
|
|
||
|
public static ViewTreeObserverOnPreDrawListenerC17759zYL c(View view, Runnable runnable) {
|
||
|
if (view == null) {
|
||
|
throw new NullPointerException("view == null");
|
||
|
}
|
||
|
ViewTreeObserverOnPreDrawListenerC17759zYL viewTreeObserverOnPreDrawListenerC17759zYL = new ViewTreeObserverOnPreDrawListenerC17759zYL(view, runnable);
|
||
|
view.getViewTreeObserver().addOnPreDrawListener(viewTreeObserverOnPreDrawListenerC17759zYL);
|
||
|
view.addOnAttachStateChangeListener(viewTreeObserverOnPreDrawListenerC17759zYL);
|
||
|
return viewTreeObserverOnPreDrawListenerC17759zYL;
|
||
|
}
|
||
|
|
||
|
@Override // android.view.ViewTreeObserver.OnPreDrawListener
|
||
|
public final boolean onPreDraw() {
|
||
|
e();
|
||
|
this.c.run();
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
private void e() {
|
||
|
if (this.d.isAlive()) {
|
||
|
this.d.removeOnPreDrawListener(this);
|
||
|
} else {
|
||
|
this.e.getViewTreeObserver().removeOnPreDrawListener(this);
|
||
|
}
|
||
|
this.e.removeOnAttachStateChangeListener(this);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View.OnAttachStateChangeListener
|
||
|
public final void onViewAttachedToWindow(View view) {
|
||
|
this.d = view.getViewTreeObserver();
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View.OnAttachStateChangeListener
|
||
|
public final void onViewDetachedFromWindow(View view) {
|
||
|
e();
|
||
|
}
|
||
|
}
|