package o;

import android.animation.Animator;
import android.animation.TimeInterpolator;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowId;
import android.widget.ListView;
import com.google.android.gms.common.api.CommonStatusCodes;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.WeakHashMap;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.yg0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public abstract class AbstractC3019yg0 implements Cloneable {
    public static final Animator[] I = new Animator[0];
    public static final int[] J = {2, 1, 3, 4};
    public static final C2616uQ K = new C2616uQ(21);
    public static final ThreadLocal L = new ThreadLocal();
    public C2887xC G;
    public ArrayList v;
    public ArrayList w;
    public InterfaceC2829wg0[] x;
    public final String l = getClass().getName();
    public long m = -1;
    public long n = -1;

    /* renamed from: o, reason: collision with root package name */
    public TimeInterpolator f808o = null;
    public final ArrayList p = new ArrayList();
    public final ArrayList q = new ArrayList();
    public S60 r = new S60(7);
    public S60 s = new S60(7);
    public Kg0 t = null;
    public final int[] u = J;
    public final ArrayList y = new ArrayList();
    public Animator[] z = I;
    public int A = 0;
    public boolean B = false;
    public boolean C = false;
    public AbstractC3019yg0 D = null;
    public ArrayList E = null;
    public ArrayList F = new ArrayList();
    public C2616uQ H = K;

    public static void c(S60 s60, View view, Ng0 ng0) {
        C1839m9 c1839m9 = (C1839m9) s60.m;
        C1839m9 c1839m92 = (C1839m9) s60.p;
        SparseArray sparseArray = (SparseArray) s60.n;
        UM um = (UM) s60.f325o;
        c1839m9.put(view, ng0);
        int id = view.getId();
        if (id >= 0) {
            if (sparseArray.indexOfKey(id) >= 0) {
                sparseArray.put(id, null);
            } else {
                sparseArray.put(id, view);
            }
        }
        WeakHashMap weakHashMap = Oj0.a;
        String strF = Gj0.f(view);
        if (strF != null) {
            if (c1839m92.containsKey(strF)) {
                c1839m92.put(strF, null);
            } else {
                c1839m92.put(strF, view);
            }
        }
        if (view.getParent() instanceof ListView) {
            ListView listView = (ListView) view.getParent();
            if (listView.getAdapter().hasStableIds()) {
                long itemIdAtPosition = listView.getItemIdAtPosition(listView.getPositionForView(view));
                if (um.c(itemIdAtPosition) < 0) {
                    view.setHasTransientState(true);
                    um.e(itemIdAtPosition, view);
                    return;
                }
                View view2 = (View) um.b(itemIdAtPosition);
                if (view2 != null) {
                    view2.setHasTransientState(false);
                    um.e(itemIdAtPosition, null);
                }
            }
        }
    }

    public static C1839m9 q() {
        ThreadLocal threadLocal = L;
        C1839m9 c1839m9 = (C1839m9) threadLocal.get();
        if (c1839m9 != null) {
            return c1839m9;
        }
        C1839m9 c1839m92 = new C1839m9(0);
        threadLocal.set(c1839m92);
        return c1839m92;
    }

    public static boolean v(Ng0 ng0, Ng0 ng02, String str) {
        Object obj = ng0.a.get(str);
        Object obj2 = ng02.a.get(str);
        if (obj == null && obj2 == null) {
            return false;
        }
        if (obj == null || obj2 == null) {
            return true;
        }
        return !obj.equals(obj2);
    }

    public void A(View view) {
        if (this.B) {
            if (!this.C) {
                ArrayList arrayList = this.y;
                int size = arrayList.size();
                Animator[] animatorArr = (Animator[]) arrayList.toArray(this.z);
                this.z = I;
                for (int i = size - 1; i >= 0; i--) {
                    Animator animator = animatorArr[i];
                    animatorArr[i] = null;
                    animator.resume();
                }
                this.z = animatorArr;
                w(this, C0387Oy.q);
            }
            this.B = false;
        }
    }

    public void B() {
        I();
        C1839m9 c1839m9Q = q();
        ArrayList arrayList = this.F;
        int size = arrayList.size();
        int i = 0;
        while (i < size) {
            Object obj = arrayList.get(i);
            i++;
            Animator animator = (Animator) obj;
            if (c1839m9Q.containsKey(animator)) {
                I();
                if (animator != null) {
                    animator.addListener(new C2165pg0(this, c1839m9Q));
                    long j = this.n;
                    if (j >= 0) {
                        animator.setDuration(j);
                    }
                    long j2 = this.m;
                    if (j2 >= 0) {
                        animator.setStartDelay(animator.getStartDelay() + j2);
                    }
                    TimeInterpolator timeInterpolator = this.f808o;
                    if (timeInterpolator != null) {
                        animator.setInterpolator(timeInterpolator);
                    }
                    animator.addListener(new X0(4, this));
                    animator.start();
                }
            }
        }
        this.F.clear();
        n();
    }

    public void C(long j) {
        this.n = j;
    }

    public void D(C2887xC c2887xC) {
        this.G = c2887xC;
    }

    public void E(TimeInterpolator timeInterpolator) {
        this.f808o = timeInterpolator;
    }

    public void F(C2616uQ c2616uQ) {
        if (c2616uQ == null) {
            this.H = K;
        } else {
            this.H = c2616uQ;
        }
    }

    public void H(long j) {
        this.m = j;
    }

    public final void I() {
        if (this.A == 0) {
            w(this, C0387Oy.m);
            this.C = false;
        }
        this.A++;
    }

    public String J(String str) {
        StringBuilder sb = new StringBuilder(str);
        sb.append(getClass().getSimpleName());
        sb.append("@");
        sb.append(Integer.toHexString(hashCode()));
        sb.append(": ");
        if (this.n != -1) {
            sb.append("dur(");
            sb.append(this.n);
            sb.append(") ");
        }
        if (this.m != -1) {
            sb.append("dly(");
            sb.append(this.m);
            sb.append(") ");
        }
        if (this.f808o != null) {
            sb.append("interp(");
            sb.append(this.f808o);
            sb.append(") ");
        }
        ArrayList arrayList = this.p;
        int size = arrayList.size();
        ArrayList arrayList2 = this.q;
        if (size > 0 || arrayList2.size() > 0) {
            sb.append("tgts(");
            if (arrayList.size() > 0) {
                for (int i = 0; i < arrayList.size(); i++) {
                    if (i > 0) {
                        sb.append(", ");
                    }
                    sb.append(arrayList.get(i));
                }
            }
            if (arrayList2.size() > 0) {
                for (int i2 = 0; i2 < arrayList2.size(); i2++) {
                    if (i2 > 0) {
                        sb.append(", ");
                    }
                    sb.append(arrayList2.get(i2));
                }
            }
            sb.append(")");
        }
        return sb.toString();
    }

    public void a(InterfaceC2829wg0 interfaceC2829wg0) {
        if (this.E == null) {
            this.E = new ArrayList();
        }
        this.E.add(interfaceC2829wg0);
    }

    public void b(View view) {
        this.q.add(view);
    }

    public void d() {
        ArrayList arrayList = this.y;
        int size = arrayList.size();
        Animator[] animatorArr = (Animator[]) arrayList.toArray(this.z);
        this.z = I;
        for (int i = size - 1; i >= 0; i--) {
            Animator animator = animatorArr[i];
            animatorArr[i] = null;
            animator.cancel();
        }
        this.z = animatorArr;
        w(this, C0387Oy.f277o);
    }

    public abstract void e(Ng0 ng0);

    public final void f(View view, boolean z) {
        if (view == null) {
            return;
        }
        view.getId();
        if (view.getParent() instanceof ViewGroup) {
            Ng0 ng0 = new Ng0(view);
            if (z) {
                h(ng0);
            } else {
                e(ng0);
            }
            ng0.c.add(this);
            g(ng0);
            if (z) {
                c(this.r, view, ng0);
            } else {
                c(this.s, view, ng0);
            }
        }
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            for (int i = 0; i < viewGroup.getChildCount(); i++) {
                f(viewGroup.getChildAt(i), z);
            }
        }
    }

    public abstract void h(Ng0 ng0);

    public final void i(ViewGroup viewGroup, boolean z) {
        j(z);
        ArrayList arrayList = this.p;
        int size = arrayList.size();
        ArrayList arrayList2 = this.q;
        if (size <= 0 && arrayList2.size() <= 0) {
            f(viewGroup, z);
            return;
        }
        for (int i = 0; i < arrayList.size(); i++) {
            View viewFindViewById = viewGroup.findViewById(((Integer) arrayList.get(i)).intValue());
            if (viewFindViewById != null) {
                Ng0 ng0 = new Ng0(viewFindViewById);
                if (z) {
                    h(ng0);
                } else {
                    e(ng0);
                }
                ng0.c.add(this);
                g(ng0);
                if (z) {
                    c(this.r, viewFindViewById, ng0);
                } else {
                    c(this.s, viewFindViewById, ng0);
                }
            }
        }
        for (int i2 = 0; i2 < arrayList2.size(); i2++) {
            View view = (View) arrayList2.get(i2);
            Ng0 ng02 = new Ng0(view);
            if (z) {
                h(ng02);
            } else {
                e(ng02);
            }
            ng02.c.add(this);
            g(ng02);
            if (z) {
                c(this.r, view, ng02);
            } else {
                c(this.s, view, ng02);
            }
        }
    }

    public final void j(boolean z) {
        if (z) {
            ((C1839m9) this.r.m).clear();
            ((SparseArray) this.r.n).clear();
            ((UM) this.r.f325o).a();
        } else {
            ((C1839m9) this.s.m).clear();
            ((SparseArray) this.s.n).clear();
            ((UM) this.s.f325o).a();
        }
    }

    @Override // 
    /* renamed from: k, reason: merged with bridge method [inline-methods] */
    public AbstractC3019yg0 clone() {
        try {
            AbstractC3019yg0 abstractC3019yg0 = (AbstractC3019yg0) super.clone();
            abstractC3019yg0.F = new ArrayList();
            abstractC3019yg0.r = new S60(7);
            abstractC3019yg0.s = new S60(7);
            abstractC3019yg0.v = null;
            abstractC3019yg0.w = null;
            abstractC3019yg0.D = this;
            abstractC3019yg0.E = null;
            return abstractC3019yg0;
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }
    }

    public Animator l(ViewGroup viewGroup, Ng0 ng0, Ng0 ng02) {
        return null;
    }

    public void m(ViewGroup viewGroup, S60 s60, S60 s602, ArrayList arrayList, ArrayList arrayList2) {
        int i;
        int i2;
        View view;
        Ng0 ng0;
        Animator animator;
        Ng0 ng02;
        C1839m9 c1839m9Q = q();
        SparseIntArray sparseIntArray = new SparseIntArray();
        int size = arrayList.size();
        p().getClass();
        int i3 = 0;
        while (i3 < size) {
            Ng0 ng03 = (Ng0) arrayList.get(i3);
            Ng0 ng04 = (Ng0) arrayList2.get(i3);
            if (ng03 != null && !ng03.c.contains(this)) {
                ng03 = null;
            }
            if (ng04 != null && !ng04.c.contains(this)) {
                ng04 = null;
            }
            if ((ng03 != null || ng04 != null) && (ng03 == null || ng04 == null || t(ng03, ng04))) {
                Animator animatorL = l(viewGroup, ng03, ng04);
                if (animatorL != null) {
                    String str = this.l;
                    if (ng04 != null) {
                        view = ng04.b;
                        String[] strArrR = r();
                        if (strArrR != null && strArrR.length > 0) {
                            ng02 = new Ng0(view);
                            Ng0 ng05 = (Ng0) ((C1839m9) s602.m).get(view);
                            i = size;
                            if (ng05 != null) {
                                int i4 = 0;
                                while (i4 < strArrR.length) {
                                    String str2 = strArrR[i4];
                                    ng02.a.put(str2, ng05.a.get(str2));
                                    i4++;
                                    i3 = i3;
                                    ng05 = ng05;
                                }
                            }
                            i2 = i3;
                            int i5 = c1839m9Q.n;
                            int i6 = 0;
                            while (true) {
                                if (i6 >= i5) {
                                    animator = animatorL;
                                    break;
                                }
                                C2260qg0 c2260qg0 = (C2260qg0) c1839m9Q.get((Animator) c1839m9Q.f(i6));
                                if (c2260qg0.c != null && c2260qg0.a == view && c2260qg0.b.equals(str) && c2260qg0.c.equals(ng02)) {
                                    animator = null;
                                    break;
                                }
                                i6++;
                            }
                        } else {
                            i = size;
                            i2 = i3;
                            animator = animatorL;
                            ng02 = null;
                        }
                        animatorL = animator;
                        ng0 = ng02;
                    } else {
                        i = size;
                        i2 = i3;
                        view = ng03.b;
                        ng0 = null;
                    }
                    if (animatorL != null) {
                        WindowId windowId = viewGroup.getWindowId();
                        C2260qg0 c2260qg02 = new C2260qg0();
                        c2260qg02.a = view;
                        c2260qg02.b = str;
                        c2260qg02.c = ng0;
                        c2260qg02.d = windowId;
                        c2260qg02.e = this;
                        c2260qg02.f = animatorL;
                        c1839m9Q.put(animatorL, c2260qg02);
                        this.F.add(animatorL);
                    }
                }
                i3 = i2 + 1;
                size = i;
            }
            i = size;
            i2 = i3;
            i3 = i2 + 1;
            size = i;
        }
        if (sparseIntArray.size() != 0) {
            for (int i7 = 0; i7 < sparseIntArray.size(); i7++) {
                C2260qg0 c2260qg03 = (C2260qg0) c1839m9Q.get((Animator) this.F.get(sparseIntArray.keyAt(i7)));
                c2260qg03.f.setStartDelay(c2260qg03.f.getStartDelay() + (sparseIntArray.valueAt(i7) - Long.MAX_VALUE));
            }
        }
    }

    public final void n() {
        int i = this.A - 1;
        this.A = i;
        if (i == 0) {
            w(this, C0387Oy.n);
            for (int i2 = 0; i2 < ((UM) this.r.f325o).g(); i2++) {
                View view = (View) ((UM) this.r.f325o).h(i2);
                if (view != null) {
                    view.setHasTransientState(false);
                }
            }
            for (int i3 = 0; i3 < ((UM) this.s.f325o).g(); i3++) {
                View view2 = (View) ((UM) this.s.f325o).h(i3);
                if (view2 != null) {
                    view2.setHasTransientState(false);
                }
            }
            this.C = true;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:21:0x002c, code lost:
    
        if (r2 < 0) goto L27;
     */
    /* JADX WARN: Code restructure failed: missing block: B:22:0x002e, code lost:
    
        if (r6 == false) goto L24;
     */
    /* JADX WARN: Code restructure failed: missing block: B:23:0x0030, code lost:
    
        r5 = r4.w;
     */
    /* JADX WARN: Code restructure failed: missing block: B:24:0x0033, code lost:
    
        r5 = r4.v;
     */
    /* JADX WARN: Code restructure failed: missing block: B:26:0x003b, code lost:
    
        return (o.Ng0) r5.get(r2);
     */
    /* JADX WARN: Code restructure failed: missing block: B:27:0x003c, code lost:
    
        return null;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final o.Ng0 o(android.view.View r5, boolean r6) {
        /*
            r4 = this;
            o.Kg0 r0 = r4.t
            if (r0 == 0) goto L9
            o.Ng0 r5 = r0.o(r5, r6)
            return r5
        L9:
            if (r6 == 0) goto Le
            java.util.ArrayList r0 = r4.v
            goto L10
        Le:
            java.util.ArrayList r0 = r4.w
        L10:
            if (r0 != 0) goto L13
            goto L3c
        L13:
            int r1 = r0.size()
            r2 = 0
        L18:
            if (r2 >= r1) goto L2b
            java.lang.Object r3 = r0.get(r2)
            o.Ng0 r3 = (o.Ng0) r3
            if (r3 != 0) goto L23
            goto L3c
        L23:
            android.view.View r3 = r3.b
            if (r3 != r5) goto L28
            goto L2c
        L28:
            int r2 = r2 + 1
            goto L18
        L2b:
            r2 = -1
        L2c:
            if (r2 < 0) goto L3c
            if (r6 == 0) goto L33
            java.util.ArrayList r5 = r4.w
            goto L35
        L33:
            java.util.ArrayList r5 = r4.v
        L35:
            java.lang.Object r5 = r5.get(r2)
            o.Ng0 r5 = (o.Ng0) r5
            return r5
        L3c:
            r5 = 0
            return r5
        */
        throw new UnsupportedOperationException("Method not decompiled: o.AbstractC3019yg0.o(android.view.View, boolean):o.Ng0");
    }

    public final AbstractC3019yg0 p() {
        Kg0 kg0 = this.t;
        return kg0 != null ? kg0.p() : this;
    }

    public String[] r() {
        return null;
    }

    public final Ng0 s(View view, boolean z) {
        Kg0 kg0 = this.t;
        if (kg0 != null) {
            return kg0.s(view, z);
        }
        return (Ng0) ((C1839m9) (z ? this.r : this.s).m).get(view);
    }

    public boolean t(Ng0 ng0, Ng0 ng02) {
        if (ng0 != null && ng02 != null) {
            String[] strArrR = r();
            if (strArrR != null) {
                for (String str : strArrR) {
                    if (v(ng0, ng02, str)) {
                        return true;
                    }
                }
            } else {
                Iterator it = ng0.a.keySet().iterator();
                while (it.hasNext()) {
                    if (v(ng0, ng02, (String) it.next())) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public final String toString() {
        return J("");
    }

    public final boolean u(View view) {
        int id = view.getId();
        ArrayList arrayList = this.p;
        int size = arrayList.size();
        ArrayList arrayList2 = this.q;
        return (size == 0 && arrayList2.size() == 0) || arrayList.contains(Integer.valueOf(id)) || arrayList2.contains(view);
    }

    public final void w(AbstractC3019yg0 abstractC3019yg0, C0387Oy c0387Oy) {
        AbstractC3019yg0 abstractC3019yg02 = this.D;
        if (abstractC3019yg02 != null) {
            abstractC3019yg02.w(abstractC3019yg0, c0387Oy);
        }
        ArrayList arrayList = this.E;
        if (arrayList == null || arrayList.isEmpty()) {
            return;
        }
        int size = this.E.size();
        InterfaceC2829wg0[] interfaceC2829wg0Arr = this.x;
        if (interfaceC2829wg0Arr == null) {
            interfaceC2829wg0Arr = new InterfaceC2829wg0[size];
        }
        this.x = null;
        InterfaceC2829wg0[] interfaceC2829wg0Arr2 = (InterfaceC2829wg0[]) this.E.toArray(interfaceC2829wg0Arr);
        for (int i = 0; i < size; i++) {
            InterfaceC2829wg0 interfaceC2829wg0 = interfaceC2829wg0Arr2[i];
            switch (c0387Oy.l) {
                case 19:
                    interfaceC2829wg0.d(abstractC3019yg0);
                    break;
                case 20:
                    interfaceC2829wg0.f(abstractC3019yg0);
                    break;
                case CommonStatusCodes.RECONNECTION_TIMED_OUT_DURING_UPDATE /* 21 */:
                    interfaceC2829wg0.a(abstractC3019yg0);
                    break;
                case 22:
                    interfaceC2829wg0.b();
                    break;
                default:
                    interfaceC2829wg0.c();
                    break;
            }
            interfaceC2829wg0Arr2[i] = null;
        }
        this.x = interfaceC2829wg0Arr2;
    }

    public void x(View view) {
        if (this.C) {
            return;
        }
        ArrayList arrayList = this.y;
        int size = arrayList.size();
        Animator[] animatorArr = (Animator[]) arrayList.toArray(this.z);
        this.z = I;
        for (int i = size - 1; i >= 0; i--) {
            Animator animator = animatorArr[i];
            animatorArr[i] = null;
            animator.pause();
        }
        this.z = animatorArr;
        w(this, C0387Oy.p);
        this.B = true;
    }

    public AbstractC3019yg0 y(InterfaceC2829wg0 interfaceC2829wg0) {
        AbstractC3019yg0 abstractC3019yg0;
        ArrayList arrayList = this.E;
        if (arrayList != null) {
            if (!arrayList.remove(interfaceC2829wg0) && (abstractC3019yg0 = this.D) != null) {
                abstractC3019yg0.y(interfaceC2829wg0);
            }
            if (this.E.size() == 0) {
                this.E = null;
            }
        }
        return this;
    }

    public void z(View view) {
        this.q.remove(view);
    }

    public void G() {
    }

    public void g(Ng0 ng0) {
    }
}
