package c.a.o; import android.view.View; import android.view.WindowManager; import androidx.core.view.ViewCompat; import com.discord.overlay.OverlayManager; import com.discord.overlay.views.OverlayBubbleWrap; import d0.z.d.m; import kotlin.jvm.functions.Function1; /* compiled from: OverlayManager.kt */ public final class d implements View.OnClickListener { public final /* synthetic */ OverlayManager i; public final /* synthetic */ Function1 j; public final /* synthetic */ OverlayBubbleWrap k; public final /* synthetic */ Object l; /* compiled from: OverlayManager.kt */ public static final class a implements View.OnAttachStateChangeListener { public final /* synthetic */ d i; /* compiled from: View.kt */ /* renamed from: c.a.o.d$a$a reason: collision with other inner class name */ public static final class View$OnLayoutChangeListenerC0029a implements View.OnLayoutChangeListener { public final /* synthetic */ a i; public final /* synthetic */ View j; public View$OnLayoutChangeListenerC0029a(a aVar, View view) { this.i = aVar; this.j = view; } @Override // android.view.View.OnLayoutChangeListener public void onLayoutChange(View view, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8) { m.checkParameterIsNotNull(view, "view"); view.removeOnLayoutChangeListener(this); View findViewWithTag = this.j.findViewWithTag(this.i.i.l); m.checkNotNullExpressionValue(findViewWithTag, "v.findViewWithTag(anchorViewTag)"); this.i.i.k.b(findViewWithTag); } } public a(d dVar) { this.i = dVar; } @Override // android.view.View.OnAttachStateChangeListener public void onViewAttachedToWindow(View view) { m.checkNotNullParameter(view, "v"); if (!ViewCompat.isLaidOut(view) || view.isLayoutRequested()) { view.addOnLayoutChangeListener(new View$OnLayoutChangeListenerC0029a(this, view)); return; } View findViewWithTag = view.findViewWithTag(this.i.l); m.checkNotNullExpressionValue(findViewWithTag, "v.findViewWithTag(anchorViewTag)"); this.i.k.b(findViewWithTag); } @Override // android.view.View.OnAttachStateChangeListener public void onViewDetachedFromWindow(View view) { if (ViewCompat.isAttachedToWindow(this.i.k)) { this.i.k.setBubbleTouchable(true); this.i.k.a(true); } } } public d(OverlayManager overlayManager, Function1 function1, OverlayBubbleWrap overlayBubbleWrap, Object obj) { this.i = overlayManager; this.j = function1; this.k = overlayBubbleWrap; this.l = obj; } @Override // android.view.View.OnClickListener public final void onClick(View view) { OverlayBubbleWrap overlayBubbleWrap = (OverlayBubbleWrap) this.j.invoke(this.k); overlayBubbleWrap.addOnAttachStateChangeListener(new a(this)); this.i.a(overlayBubbleWrap); this.k.setBubbleTouchable(false); this.i.r.removeViewImmediate(this.k); WindowManager windowManager = this.i.r; OverlayBubbleWrap overlayBubbleWrap2 = this.k; windowManager.addView(overlayBubbleWrap2, overlayBubbleWrap2.getWindowLayoutParams()); } }