package v2;

import C0.J;
import android.animation.Animator;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowId;
import java.util.ArrayList;
import java.util.Iterator;
import n.C2578e;
import n.C2592t;

/* JADX INFO: renamed from: v2.t, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class ViewTreeObserverOnPreDrawListenerC3121t implements ViewTreeObserver.OnPreDrawListener, View.OnAttachStateChangeListener {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public AbstractC3118q f25378a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public ViewGroup f25379b;

    /* JADX WARN: Removed duplicated region for block: B:101:0x021f  */
    /* JADX WARN: Removed duplicated region for block: B:108:0x0250  */
    /* JADX WARN: Removed duplicated region for block: B:135:0x02bc  */
    /* JADX WARN: Removed duplicated region for block: B:142:0x01f7 A[EDGE_INSN: B:142:0x01f7->B:91:0x01f7 BREAK  A[LOOP:1: B:19:0x0087->B:90:0x01ed], SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:14:0x004e  */
    /* JADX WARN: Removed duplicated region for block: B:21:0x008c  */
    /* JADX WARN: Removed duplicated region for block: B:94:0x01fe  */
    @Override // android.view.ViewTreeObserver.OnPreDrawListener
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean onPreDraw() {
        ArrayList arrayList;
        AbstractC3118q abstractC3118q;
        int i6;
        J j4;
        C2578e c2578e;
        C2578e c2578e2;
        int i7;
        int[] iArr;
        int i8;
        int i9;
        ArrayList arrayList2;
        int i10;
        int i11;
        C3115n c3115n;
        View view;
        J j6;
        boolean z6;
        C3126y c3126y;
        View view2;
        J j7;
        boolean z7;
        ViewGroup viewGroup = this.f25379b;
        viewGroup.getViewTreeObserver().removeOnPreDrawListener(this);
        viewGroup.removeOnAttachStateChangeListener(this);
        ArrayList arrayList3 = AbstractC3122u.f25381b;
        ViewGroup viewGroup2 = this.f25379b;
        boolean z8 = true;
        if (!arrayList3.remove(viewGroup2)) {
            return true;
        }
        C2578e c2578eA = AbstractC3122u.a();
        ArrayList arrayList4 = (ArrayList) c2578eA.get(viewGroup2);
        if (arrayList4 != null) {
            arrayList = arrayList4.size() > 0 ? new ArrayList(arrayList4) : null;
            abstractC3118q = this.f25378a;
            arrayList4.add(abstractC3118q);
            abstractC3118q.a(new C3120s(this, c2578eA));
            i6 = 0;
            abstractC3118q.i(viewGroup2, false);
            if (arrayList != null) {
                Iterator it = arrayList.iterator();
                while (it.hasNext()) {
                    ((AbstractC3118q) it.next()).A(viewGroup2);
                }
            }
            abstractC3118q.l = new ArrayList();
            abstractC3118q.f25364m = new ArrayList();
            j4 = abstractC3118q.f25360e;
            J j8 = abstractC3118q.f25361f;
            c2578e = new C2578e((C2578e) j4.f533b);
            c2578e2 = new C2578e((C2578e) j8.f533b);
            i7 = 0;
            while (true) {
                iArr = abstractC3118q.f25363k;
                if (i7 < iArr.length) {
                    break;
                }
                int i12 = iArr[i7];
                if (i12 == z8) {
                    j6 = j4;
                    z6 = z8;
                    for (int i13 = c2578e.f21416c - 1; i13 >= 0; i13--) {
                        View view3 = (View) c2578e.g(i13);
                        if (view3 != null && abstractC3118q.u(view3) && (c3126y = (C3126y) c2578e2.remove(view3)) != null && abstractC3118q.u(c3126y.f25392b)) {
                            abstractC3118q.l.add((C3126y) c2578e.h(i13));
                            abstractC3118q.f25364m.add(c3126y);
                        }
                    }
                } else if (i12 == 2) {
                    j6 = j4;
                    z6 = z8;
                    C2578e c2578e3 = (C2578e) j6.f536e;
                    int i14 = c2578e3.f21416c;
                    for (int i15 = 0; i15 < i14; i15++) {
                        View view4 = (View) c2578e3.j(i15);
                        if (view4 != null && abstractC3118q.u(view4)) {
                            View view5 = (View) ((C2578e) j8.f536e).get((String) c2578e3.g(i15));
                            if (view5 != null && abstractC3118q.u(view5)) {
                                C3126y c3126y2 = (C3126y) c2578e.get(view4);
                                C3126y c3126y3 = (C3126y) c2578e2.get(view5);
                                if (c3126y2 != null && c3126y3 != null) {
                                    abstractC3118q.l.add(c3126y2);
                                    abstractC3118q.f25364m.add(c3126y3);
                                    c2578e.remove(view4);
                                    c2578e2.remove(view5);
                                }
                            }
                        }
                    }
                } else if (i12 == 3) {
                    j6 = j4;
                    z6 = z8;
                    SparseArray sparseArray = (SparseArray) j6.f534c;
                    SparseArray sparseArray2 = (SparseArray) j8.f534c;
                    int size = sparseArray.size();
                    for (int i16 = 0; i16 < size; i16++) {
                        View view6 = (View) sparseArray.valueAt(i16);
                        if (view6 != null && abstractC3118q.u(view6) && (view2 = (View) sparseArray2.get(sparseArray.keyAt(i16))) != null && abstractC3118q.u(view2)) {
                            C3126y c3126y4 = (C3126y) c2578e.get(view6);
                            C3126y c3126y5 = (C3126y) c2578e2.get(view2);
                            if (c3126y4 != null && c3126y5 != null) {
                                abstractC3118q.l.add(c3126y4);
                                abstractC3118q.f25364m.add(c3126y5);
                                c2578e.remove(view6);
                                c2578e2.remove(view2);
                            }
                        }
                    }
                } else if (i12 != 4) {
                    j6 = j4;
                    z6 = z8;
                } else {
                    C2592t c2592t = (C2592t) j4.f535d;
                    int iH = c2592t.h();
                    int i17 = i6;
                    while (i17 < iH) {
                        View view7 = (View) c2592t.i(i17);
                        if (view7 == null || !abstractC3118q.u(view7)) {
                            j7 = j4;
                        } else {
                            j7 = j4;
                            View view8 = (View) ((C2592t) j8.f535d).b(c2592t.d(i17));
                            if (view8 != null && abstractC3118q.u(view8)) {
                                C3126y c3126y6 = (C3126y) c2578e.get(view7);
                                C3126y c3126y7 = (C3126y) c2578e2.get(view8);
                                if (c3126y6 != null && c3126y7 != null) {
                                    z7 = z8;
                                    abstractC3118q.l.add(c3126y6);
                                    abstractC3118q.f25364m.add(c3126y7);
                                    c2578e.remove(view7);
                                    c2578e2.remove(view8);
                                }
                            }
                            i17++;
                            j4 = j7;
                            z8 = z7;
                        }
                        z7 = z8;
                        i17++;
                        j4 = j7;
                        z8 = z7;
                    }
                    z6 = z8;
                    j6 = j4;
                }
                i7++;
                j4 = j6;
                z8 = z6;
                i6 = 0;
            }
            boolean z9 = z8;
            for (i8 = 0; i8 < c2578e.f21416c; i8++) {
                C3126y c3126y8 = (C3126y) c2578e.j(i8);
                if (abstractC3118q.u(c3126y8.f25392b)) {
                    abstractC3118q.l.add(c3126y8);
                    abstractC3118q.f25364m.add(null);
                }
            }
            for (i9 = 0; i9 < c2578e2.f21416c; i9++) {
                C3126y c3126y9 = (C3126y) c2578e2.j(i9);
                if (abstractC3118q.u(c3126y9.f25392b)) {
                    abstractC3118q.f25364m.add(c3126y9);
                    abstractC3118q.l.add(null);
                }
            }
            C2578e c2578eQ = AbstractC3118q.q();
            int i18 = c2578eQ.f21416c;
            WindowId windowId = viewGroup2.getWindowId();
            arrayList2 = new ArrayList();
            i10 = i18 - 1;
            while (i10 >= 0) {
                Animator animator = (Animator) c2578eQ.g(i10);
                if (animator != null && (c3115n = (C3115n) c2578eQ.get(animator)) != null && (view = c3115n.f25341a) != null && windowId.equals(c3115n.f25344d)) {
                    boolean z10 = z9;
                    C3126y c3126yS = abstractC3118q.s(view, z10);
                    C3126y c3126yO = abstractC3118q.o(view, z10);
                    if (c3126yS == null && c3126yO == null) {
                        c3126yO = (C3126y) ((C2578e) abstractC3118q.f25361f.f533b).get(view);
                    }
                    if (c3126yS != null || c3126yO != null) {
                        C3126y c3126y10 = c3115n.f25343c;
                        AbstractC3118q abstractC3118q2 = c3115n.f25345e;
                        if (abstractC3118q2.t(c3126y10, c3126yO)) {
                            abstractC3118q2.p().getClass();
                            if (animator.isRunning() || animator.isStarted()) {
                                animator.cancel();
                            } else {
                                c2578eQ.h(i10);
                            }
                        }
                    }
                }
                i10--;
                z9 = true;
            }
            for (i11 = 0; i11 < arrayList2.size(); i11++) {
                AbstractC3118q abstractC3118q3 = (AbstractC3118q) arrayList2.get(i11);
                abstractC3118q3.w(abstractC3118q3, InterfaceC3117p.f25349c);
                if (!abstractC3118q3.f25370s) {
                    abstractC3118q3.f25370s = true;
                    abstractC3118q3.w(abstractC3118q3, InterfaceC3117p.f25348b);
                }
            }
            abstractC3118q.m(viewGroup2, abstractC3118q.f25360e, abstractC3118q.f25361f, abstractC3118q.l, abstractC3118q.f25364m);
            abstractC3118q.B();
            return true;
        }
        arrayList4 = new ArrayList();
        c2578eA.put(viewGroup2, arrayList4);
        abstractC3118q = this.f25378a;
        arrayList4.add(abstractC3118q);
        abstractC3118q.a(new C3120s(this, c2578eA));
        i6 = 0;
        abstractC3118q.i(viewGroup2, false);
        if (arrayList != null) {
        }
        abstractC3118q.l = new ArrayList();
        abstractC3118q.f25364m = new ArrayList();
        j4 = abstractC3118q.f25360e;
        J j82 = abstractC3118q.f25361f;
        c2578e = new C2578e((C2578e) j4.f533b);
        c2578e2 = new C2578e((C2578e) j82.f533b);
        i7 = 0;
        while (true) {
            iArr = abstractC3118q.f25363k;
            if (i7 < iArr.length) {
            }
            i7++;
            j4 = j6;
            z8 = z6;
            i6 = 0;
        }
        boolean z92 = z8;
        while (i8 < c2578e.f21416c) {
        }
        while (i9 < c2578e2.f21416c) {
        }
        C2578e c2578eQ2 = AbstractC3118q.q();
        int i182 = c2578eQ2.f21416c;
        WindowId windowId2 = viewGroup2.getWindowId();
        arrayList2 = new ArrayList();
        i10 = i182 - 1;
        while (i10 >= 0) {
        }
        while (i11 < arrayList2.size()) {
        }
        abstractC3118q.m(viewGroup2, abstractC3118q.f25360e, abstractC3118q.f25361f, abstractC3118q.l, abstractC3118q.f25364m);
        abstractC3118q.B();
        return true;
    }

    @Override // android.view.View.OnAttachStateChangeListener
    public final void onViewDetachedFromWindow(View view) {
        ViewGroup viewGroup = this.f25379b;
        viewGroup.getViewTreeObserver().removeOnPreDrawListener(this);
        viewGroup.removeOnAttachStateChangeListener(this);
        ArrayList arrayList = AbstractC3122u.f25381b;
        ViewGroup viewGroup2 = this.f25379b;
        arrayList.remove(viewGroup2);
        ArrayList arrayList2 = (ArrayList) AbstractC3122u.a().get(viewGroup2);
        if (arrayList2 != null && arrayList2.size() > 0) {
            Iterator it = arrayList2.iterator();
            while (it.hasNext()) {
                ((AbstractC3118q) it.next()).A(viewGroup2);
            }
        }
        this.f25378a.j(true);
    }

    @Override // android.view.View.OnAttachStateChangeListener
    public final void onViewAttachedToWindow(View view) {
    }
}
