package o;

import android.content.Context;
import android.view.View;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityManager;
import com.google.android.gms.common.R;
import java.util.Iterator;
import java.util.WeakHashMap;

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

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

    @Override // android.view.View.OnAttachStateChangeListener
    public final void onViewAttachedToWindow(View view) {
        int i = this.l;
        Object obj = this.m;
        switch (i) {
            case 0:
                C2966y3 c2966y3 = (C2966y3) obj;
                AccessibilityManager accessibilityManager = c2966y3.g;
                c2966y3.k = accessibilityManager.getEnabledAccessibilityServiceList(-1);
                accessibilityManager.addAccessibilityStateChangeListener(c2966y3.i);
                accessibilityManager.addTouchExplorationStateChangeListener(c2966y3.j);
                break;
            case 1:
                C2398s4 c2398s4 = (C2398s4) obj;
                Context context = view.getContext();
                if (!c2398s4.a) {
                    context.getApplicationContext().registerComponentCallbacks((ComponentCallbacks2C2303r4) c2398s4.e);
                    c2398s4.a = true;
                    break;
                }
                break;
            case 3:
                C0957cw c0957cw = (C0957cw) obj;
                AccessibilityManager accessibilityManager2 = c0957cw.E;
                if (c0957cw.F != null && accessibilityManager2 != null) {
                    WeakHashMap weakHashMap = Oj0.a;
                    if (c0957cw.isAttachedToWindow()) {
                        accessibilityManager2.addTouchExplorationStateChangeListener(new AccessibilityManagerTouchExplorationStateChangeListenerC2675v0(c0957cw.F));
                        break;
                    }
                }
                break;
            case 4:
                View view2 = (View) obj;
                view2.removeOnAttachStateChangeListener(this);
                WeakHashMap weakHashMap2 = Oj0.a;
                Ej0.c(view2);
                break;
        }
    }

    @Override // android.view.View.OnAttachStateChangeListener
    public final void onViewDetachedFromWindow(View view) {
        AccessibilityManager accessibilityManager;
        boolean z;
        switch (this.l) {
            case 0:
                C2966y3 c2966y3 = (C2966y3) this.m;
                c2966y3.l.removeCallbacks(c2966y3.N);
                AccessibilityManager accessibilityManager2 = c2966y3.g;
                accessibilityManager2.removeAccessibilityStateChangeListener(c2966y3.i);
                accessibilityManager2.removeTouchExplorationStateChangeListener(c2966y3.j);
                break;
            case 1:
                C2398s4 c2398s4 = (C2398s4) this.m;
                Context context = view.getContext();
                if (c2398s4.a) {
                    context.getApplicationContext().unregisterComponentCallbacks((ComponentCallbacks2C2303r4) c2398s4.e);
                    c2398s4.a = false;
                    break;
                }
                break;
            case 2:
                ViewOnKeyListenerC0317Mg viewOnKeyListenerC0317Mg = (ViewOnKeyListenerC0317Mg) this.m;
                ViewTreeObserver viewTreeObserver = viewOnKeyListenerC0317Mg.I;
                if (viewTreeObserver != null) {
                    if (!viewTreeObserver.isAlive()) {
                        viewOnKeyListenerC0317Mg.I = view.getViewTreeObserver();
                    }
                    viewOnKeyListenerC0317Mg.I.removeGlobalOnLayoutListener(viewOnKeyListenerC0317Mg.t);
                }
                view.removeOnAttachStateChangeListener(this);
                break;
            case 3:
                C0957cw c0957cw = (C0957cw) this.m;
                G1 g1 = c0957cw.F;
                if (g1 != null && (accessibilityManager = c0957cw.E) != null) {
                    accessibilityManager.removeTouchExplorationStateChangeListener(new AccessibilityManagerTouchExplorationStateChangeListenerC2675v0(g1));
                    break;
                }
                break;
            case 4:
                break;
            case 5:
                ViewOnKeyListenerC2248qa0 viewOnKeyListenerC2248qa0 = (ViewOnKeyListenerC2248qa0) this.m;
                ViewTreeObserver viewTreeObserver2 = viewOnKeyListenerC2248qa0.z;
                if (viewTreeObserver2 != null) {
                    if (!viewTreeObserver2.isAlive()) {
                        viewOnKeyListenerC2248qa0.z = view.getViewTreeObserver();
                    }
                    viewOnKeyListenerC2248qa0.z.removeGlobalOnLayoutListener(viewOnKeyListenerC2248qa0.t);
                }
                view.removeOnAttachStateChangeListener(this);
                break;
            case 6:
                AbstractC3054z abstractC3054z = (AbstractC3054z) this.m;
                ViewParent parent = abstractC3054z.getParent();
                Iterator it = (parent == null ? C0436Qv.a : new GD(new U4(23, parent), Yj0.t)).iterator();
                while (true) {
                    if (it.hasNext()) {
                        Object obj = (ViewParent) it.next();
                        if (obj instanceof View) {
                            Object tag = ((View) obj).getTag(R.id.is_pooling_container_tag);
                            Boolean bool = tag instanceof Boolean ? (Boolean) tag : null;
                            if (bool != null ? bool.booleanValue() : false) {
                                z = true;
                            }
                        }
                    }
                }
                if (!z) {
                    Qm0 qm0 = abstractC3054z.n;
                    if (qm0 != null) {
                        qm0.a();
                    }
                    abstractC3054z.n = null;
                    abstractC3054z.requestLayout();
                    break;
                }
                break;
            default:
                view.removeOnAttachStateChangeListener(this);
                ((C2058oa0) this.m).c(null);
                break;
        }
    }

    private final void a(View view) {
    }

    private final void b(View view) {
    }

    private final void c(View view) {
    }

    private final void d(View view) {
    }

    private final void e(View view) {
    }
}
