package o;

import android.view.View;
import android.view.ViewTreeObserver;
import java.util.ArrayList;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.k8, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class ViewTreeObserverOnGlobalLayoutListenerC1647k8 implements ViewTreeObserver.OnGlobalLayoutListener {
    public final /* synthetic */ int l;
    public final /* synthetic */ Object m;

    public /* synthetic */ ViewTreeObserverOnGlobalLayoutListenerC1647k8(int i, Object obj) {
        this.l = i;
        this.m = obj;
    }

    @Override // android.view.ViewTreeObserver.OnGlobalLayoutListener
    public final void onGlobalLayout() {
        switch (this.l) {
            case 0:
                C2501t8 c2501t8 = (C2501t8) this.m;
                if (!c2501t8.getInternalPopup().b()) {
                    c2501t8.q.n(c2501t8.getTextDirection(), c2501t8.getTextAlignment());
                }
                ViewTreeObserver viewTreeObserver = c2501t8.getViewTreeObserver();
                if (viewTreeObserver != null) {
                    viewTreeObserver.removeOnGlobalLayoutListener(this);
                    break;
                }
                break;
            case 1:
                C2217q8 c2217q8 = (C2217q8) this.m;
                C2501t8 c2501t82 = c2217q8.R;
                c2217q8.getClass();
                if (!c2501t82.isAttachedToWindow() || !c2501t82.getGlobalVisibleRect(c2217q8.P)) {
                    c2217q8.dismiss();
                    break;
                } else {
                    c2217q8.s();
                    c2217q8.e();
                    break;
                }
                break;
            case 2:
                ViewOnKeyListenerC0317Mg viewOnKeyListenerC0317Mg = (ViewOnKeyListenerC0317Mg) this.m;
                ArrayList arrayList = viewOnKeyListenerC0317Mg.s;
                if (viewOnKeyListenerC0317Mg.b() && arrayList.size() > 0) {
                    int i = 0;
                    if (!((C0292Lg) arrayList.get(0)).a.J) {
                        View view = viewOnKeyListenerC0317Mg.z;
                        if (view != null && view.isShown()) {
                            int size = arrayList.size();
                            while (i < size) {
                                Object obj = arrayList.get(i);
                                i++;
                                ((C0292Lg) obj).a.e();
                            }
                            break;
                        } else {
                            viewOnKeyListenerC0317Mg.dismiss();
                            break;
                        }
                    }
                }
                break;
            default:
                ViewOnKeyListenerC2248qa0 viewOnKeyListenerC2248qa0 = (ViewOnKeyListenerC2248qa0) this.m;
                C0711aP c0711aP = viewOnKeyListenerC2248qa0.s;
                if (viewOnKeyListenerC2248qa0.b() && !c0711aP.J) {
                    View view2 = viewOnKeyListenerC2248qa0.x;
                    if (view2 != null && view2.isShown()) {
                        c0711aP.e();
                        break;
                    } else {
                        viewOnKeyListenerC2248qa0.dismiss();
                        break;
                    }
                }
                break;
        }
    }
}
