package defpackage;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.TimeInterpolator;
import android.graphics.Path;
import android.graphics.Rect;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.WeakHashMap;

/* JADX INFO: loaded from: classes.dex */
public abstract class au9 implements Cloneable {
    static final boolean DBG = false;
    private static final String LOG_TAG = "Transition";
    private static final int MATCH_FIRST = 1;
    public static final int MATCH_ID = 3;
    private static final String MATCH_ID_STR = "id";
    public static final int MATCH_INSTANCE = 1;
    private static final String MATCH_INSTANCE_STR = "instance";
    public static final int MATCH_ITEM_ID = 4;
    private static final String MATCH_ITEM_ID_STR = "itemId";
    private static final int MATCH_LAST = 4;
    public static final int MATCH_NAME = 2;
    private static final String MATCH_NAME_STR = "name";
    private ArrayList<hv9> mEndValuesList;
    private e mEpicenterCallback;
    private ts<String, String> mNameOverrides;
    cv9 mPropagation;
    private ArrayList<hv9> mStartValuesList;
    private static final int[] DEFAULT_MATCH_ORDER = {2, 1, 3, 4};
    private static final h47 STRAIGHT_PATH_MOTION = new b();
    private static ThreadLocal<ts<Animator, c>> sRunningAnimators = new ThreadLocal<>();
    private String mName = getClass().getName();
    private long mStartDelay = -1;
    long mDuration = -1;
    private TimeInterpolator mInterpolator = null;
    ArrayList<Integer> mTargetIds = new ArrayList<>();
    ArrayList<View> mTargets = new ArrayList<>();
    private ArrayList<String> mTargetNames = null;
    private ArrayList<Class<?>> mTargetTypes = null;
    private ArrayList<Integer> mTargetIdExcludes = null;
    private ArrayList<View> mTargetExcludes = null;
    private ArrayList<Class<?>> mTargetTypeExcludes = null;
    private ArrayList<String> mTargetNameExcludes = null;
    private ArrayList<Integer> mTargetIdChildExcludes = null;
    private ArrayList<View> mTargetChildExcludes = null;
    private ArrayList<Class<?>> mTargetTypeChildExcludes = null;
    private iv9 mStartValues = new iv9();
    private iv9 mEndValues = new iv9();
    fv9 mParent = null;
    private int[] mMatchOrder = DEFAULT_MATCH_ORDER;
    boolean mCanRemoveViews = false;
    ArrayList<Animator> mCurrentAnimators = new ArrayList<>();
    private int mNumInstances = 0;
    private boolean mPaused = false;
    private boolean mEnded = false;
    private ArrayList<g> mListeners = null;
    private ArrayList<Animator> mAnimators = new ArrayList<>();
    private h47 mPathMotion = STRAIGHT_PATH_MOTION;

    public class a extends AnimatorListenerAdapter {
        public a() {
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
        public final void onAnimationEnd(Animator animator) {
            au9.this.end();
            animator.removeListener(this);
        }
    }

    public class b extends h47 {
        @Override // defpackage.h47
        public final Path getPath(float f, float f2, float f3, float f4) {
            Path path = new Path();
            path.moveTo(f, f2);
            path.lineTo(f3, f4);
            return path;
        }
    }

    public static class c {
        public View a;
        public String b;
        public hv9 c;
        public jqa d;
        public au9 e;
    }

    public static class d {
        public static ArrayList a(Object obj, ArrayList arrayList) {
            if (arrayList == null) {
                arrayList = new ArrayList();
            }
            if (!arrayList.contains(obj)) {
                arrayList.add(obj);
            }
            return arrayList;
        }

        public static ArrayList b(Object obj, ArrayList arrayList) {
            if (arrayList != null) {
                arrayList.remove(obj);
                if (arrayList.isEmpty()) {
                    return null;
                }
            }
            return arrayList;
        }
    }

    public static abstract class e {
        public abstract Rect a();
    }

    @m38
    @Retention(RetentionPolicy.SOURCE)
    public @interface f {
    }

    public interface g {
        void onTransitionCancel(au9 au9Var);

        void onTransitionEnd(au9 au9Var);

        void onTransitionPause(au9 au9Var);

        void onTransitionResume(au9 au9Var);

        void onTransitionStart(au9 au9Var);
    }

    public static void a(iv9 iv9Var, View view, hv9 hv9Var) {
        ts tsVar = iv9Var.a;
        ts tsVar2 = iv9Var.d;
        SparseArray sparseArray = iv9Var.b;
        hj5 hj5Var = iv9Var.c;
        tsVar.put(view, hv9Var);
        int id = view.getId();
        if (id >= 0) {
            if (sparseArray.indexOfKey(id) >= 0) {
                sparseArray.put(id, null);
            } else {
                sparseArray.put(id, view);
            }
        }
        String strM = sia.m(view);
        if (strM != null) {
            if (tsVar2.containsKey(strM)) {
                tsVar2.put(strM, null);
            } else {
                tsVar2.put(strM, view);
            }
        }
        if (view.getParent() instanceof ListView) {
            ListView listView = (ListView) view.getParent();
            if (listView.getAdapter().hasStableIds()) {
                long itemIdAtPosition = listView.getItemIdAtPosition(listView.getPositionForView(view));
                if (hj5Var.e(itemIdAtPosition) < 0) {
                    view.setHasTransientState(true);
                    hj5Var.g(itemIdAtPosition, view);
                    return;
                }
                View view2 = (View) hj5Var.c(itemIdAtPosition);
                if (view2 != null) {
                    view2.setHasTransientState(false);
                    hj5Var.g(itemIdAtPosition, null);
                }
            }
        }
    }

    public static ts c() {
        ts<Animator, c> tsVar = sRunningAnimators.get();
        if (tsVar != null) {
            return tsVar;
        }
        ts<Animator, c> tsVar2 = new ts<>(0);
        sRunningAnimators.set(tsVar2);
        return tsVar2;
    }

    public static boolean d(hv9 hv9Var, hv9 hv9Var2, String str) {
        Object obj = hv9Var.a.get(str);
        Object obj2 = hv9Var2.a.get(str);
        if (obj == null && obj2 == null) {
            return false;
        }
        if (obj == null || obj2 == null) {
            return true;
        }
        return !obj.equals(obj2);
    }

    @vo6
    public au9 addListener(@vo6 g gVar) {
        if (this.mListeners == null) {
            this.mListeners = new ArrayList<>();
        }
        this.mListeners.add(gVar);
        return this;
    }

    @vo6
    public au9 addTarget(@vo6 View view) {
        this.mTargets.add(view);
        return this;
    }

    @m38
    public void animate(Animator animator) {
        if (animator == null) {
            end();
            return;
        }
        if (getDuration() >= 0) {
            animator.setDuration(getDuration());
        }
        if (getStartDelay() >= 0) {
            animator.setStartDelay(animator.getStartDelay() + getStartDelay());
        }
        if (getInterpolator() != null) {
            animator.setInterpolator(getInterpolator());
        }
        animator.addListener(new a());
        animator.start();
    }

    public final void b(View view, boolean z) {
        if (view == null) {
            return;
        }
        int id = view.getId();
        ArrayList<Integer> arrayList = this.mTargetIdExcludes;
        if (arrayList == null || !arrayList.contains(Integer.valueOf(id))) {
            ArrayList<View> arrayList2 = this.mTargetExcludes;
            if (arrayList2 == null || !arrayList2.contains(view)) {
                ArrayList<Class<?>> arrayList3 = this.mTargetTypeExcludes;
                if (arrayList3 != null) {
                    int size = arrayList3.size();
                    for (int i = 0; i < size; i++) {
                        if (this.mTargetTypeExcludes.get(i).isInstance(view)) {
                            return;
                        }
                    }
                }
                if (view.getParent() instanceof ViewGroup) {
                    hv9 hv9Var = new hv9(view);
                    if (z) {
                        captureStartValues(hv9Var);
                    } else {
                        captureEndValues(hv9Var);
                    }
                    hv9Var.c.add(this);
                    capturePropagationValues(hv9Var);
                    if (z) {
                        a(this.mStartValues, view, hv9Var);
                    } else {
                        a(this.mEndValues, view, hv9Var);
                    }
                }
                if (view instanceof ViewGroup) {
                    ArrayList<Integer> arrayList4 = this.mTargetIdChildExcludes;
                    if (arrayList4 == null || !arrayList4.contains(Integer.valueOf(id))) {
                        ArrayList<View> arrayList5 = this.mTargetChildExcludes;
                        if (arrayList5 == null || !arrayList5.contains(view)) {
                            ArrayList<Class<?>> arrayList6 = this.mTargetTypeChildExcludes;
                            if (arrayList6 != null) {
                                int size2 = arrayList6.size();
                                for (int i2 = 0; i2 < size2; i2++) {
                                    if (this.mTargetTypeChildExcludes.get(i2).isInstance(view)) {
                                        return;
                                    }
                                }
                            }
                            ViewGroup viewGroup = (ViewGroup) view;
                            for (int i3 = 0; i3 < viewGroup.getChildCount(); i3++) {
                                b(viewGroup.getChildAt(i3), z);
                            }
                        }
                    }
                }
            }
        }
    }

    @m38
    public void cancel() {
        for (int size = this.mCurrentAnimators.size() - 1; size >= 0; size--) {
            this.mCurrentAnimators.get(size).cancel();
        }
        ArrayList<g> arrayList = this.mListeners;
        if (arrayList == null || arrayList.size() <= 0) {
            return;
        }
        ArrayList arrayList2 = (ArrayList) this.mListeners.clone();
        int size2 = arrayList2.size();
        for (int i = 0; i < size2; i++) {
            ((g) arrayList2.get(i)).onTransitionCancel(this);
        }
    }

    public abstract void captureEndValues(hv9 hv9Var);

    public void capturePropagationValues(hv9 hv9Var) {
        if (this.mPropagation == null || hv9Var.a.isEmpty()) {
            return;
        }
        this.mPropagation.getClass();
        for (int i = 0; i < 2; i++) {
            if (!hv9Var.a.containsKey(rma.a[i])) {
                this.mPropagation.a(hv9Var);
                return;
            }
        }
    }

    public abstract void captureStartValues(hv9 hv9Var);

    public void captureValues(ViewGroup viewGroup, boolean z) {
        ArrayList<String> arrayList;
        ArrayList<Class<?>> arrayList2;
        ts<String, String> tsVar;
        clearValues(z);
        if ((this.mTargetIds.size() > 0 || this.mTargets.size() > 0) && (((arrayList = this.mTargetNames) == null || arrayList.isEmpty()) && ((arrayList2 = this.mTargetTypes) == null || arrayList2.isEmpty()))) {
            for (int i = 0; i < this.mTargetIds.size(); i++) {
                View viewFindViewById = viewGroup.findViewById(this.mTargetIds.get(i).intValue());
                if (viewFindViewById != null) {
                    hv9 hv9Var = new hv9(viewFindViewById);
                    if (z) {
                        captureStartValues(hv9Var);
                    } else {
                        captureEndValues(hv9Var);
                    }
                    hv9Var.c.add(this);
                    capturePropagationValues(hv9Var);
                    if (z) {
                        a(this.mStartValues, viewFindViewById, hv9Var);
                    } else {
                        a(this.mEndValues, viewFindViewById, hv9Var);
                    }
                }
            }
            for (int i2 = 0; i2 < this.mTargets.size(); i2++) {
                View view = this.mTargets.get(i2);
                hv9 hv9Var2 = new hv9(view);
                if (z) {
                    captureStartValues(hv9Var2);
                } else {
                    captureEndValues(hv9Var2);
                }
                hv9Var2.c.add(this);
                capturePropagationValues(hv9Var2);
                if (z) {
                    a(this.mStartValues, view, hv9Var2);
                } else {
                    a(this.mEndValues, view, hv9Var2);
                }
            }
        } else {
            b(viewGroup, z);
        }
        if (z || (tsVar = this.mNameOverrides) == null) {
            return;
        }
        int i3 = tsVar.c;
        ArrayList arrayList3 = new ArrayList(i3);
        for (int i4 = 0; i4 < i3; i4++) {
            arrayList3.add(this.mStartValues.d.remove((String) this.mNameOverrides.f(i4)));
        }
        for (int i5 = 0; i5 < i3; i5++) {
            View view2 = (View) arrayList3.get(i5);
            if (view2 != null) {
                this.mStartValues.d.put((String) this.mNameOverrides.j(i5), view2);
            }
        }
    }

    public void clearValues(boolean z) {
        if (z) {
            this.mStartValues.a.clear();
            this.mStartValues.b.clear();
            this.mStartValues.c.a();
        } else {
            this.mEndValues.a.clear();
            this.mEndValues.b.clear();
            this.mEndValues.c.a();
        }
    }

    public Animator createAnimator(ViewGroup viewGroup, hv9 hv9Var, hv9 hv9Var2) {
        return null;
    }

    @m38
    public void createAnimators(ViewGroup viewGroup, iv9 iv9Var, iv9 iv9Var2, ArrayList<hv9> arrayList, ArrayList<hv9> arrayList2) {
        Animator animatorCreateAnimator;
        int i;
        int i2;
        View view;
        hv9 hv9Var;
        Animator animator;
        hv9 hv9Var2;
        int i3;
        ts tsVarC = c();
        SparseIntArray sparseIntArray = new SparseIntArray();
        int size = arrayList.size();
        long jMin = Long.MAX_VALUE;
        int i4 = 0;
        while (i4 < size) {
            hv9 hv9Var3 = arrayList.get(i4);
            hv9 hv9Var4 = arrayList2.get(i4);
            if (hv9Var3 != null && !hv9Var3.c.contains(this)) {
                hv9Var3 = null;
            }
            if (hv9Var4 != null && !hv9Var4.c.contains(this)) {
                hv9Var4 = null;
            }
            if (!(hv9Var3 == null && hv9Var4 == null) && ((hv9Var3 == null || hv9Var4 == null || isTransitionRequired(hv9Var3, hv9Var4)) && (animatorCreateAnimator = createAnimator(viewGroup, hv9Var3, hv9Var4)) != null)) {
                if (hv9Var4 != null) {
                    view = hv9Var4.b;
                    String[] transitionProperties = getTransitionProperties();
                    if (transitionProperties != null && transitionProperties.length > 0) {
                        hv9 hv9Var5 = new hv9(view);
                        i = size;
                        i2 = i4;
                        hv9 hv9Var6 = (hv9) iv9Var2.a.get(view);
                        if (hv9Var6 != null) {
                            int i5 = 0;
                            while (i5 < transitionProperties.length) {
                                String str = transitionProperties[i5];
                                hv9Var5.a.put(str, hv9Var6.a.get(str));
                                i5++;
                                transitionProperties = transitionProperties;
                            }
                        }
                        int i6 = tsVarC.c;
                        int i7 = 0;
                        while (true) {
                            if (i7 >= i6) {
                                hv9Var2 = hv9Var5;
                                animator = animatorCreateAnimator;
                                break;
                            }
                            c cVar = (c) tsVarC.get((Animator) tsVarC.f(i7));
                            if (cVar.c != null && cVar.a == view) {
                                i3 = i6;
                                if (cVar.b.equals(getName()) && cVar.c.equals(hv9Var5)) {
                                    hv9Var2 = hv9Var5;
                                    animator = null;
                                    break;
                                }
                            } else {
                                i3 = i6;
                            }
                            i7++;
                            i6 = i3;
                        }
                    } else {
                        i = size;
                        i2 = i4;
                        animator = animatorCreateAnimator;
                        hv9Var2 = null;
                    }
                    animatorCreateAnimator = animator;
                    hv9Var = hv9Var2;
                } else {
                    i = size;
                    i2 = i4;
                    view = hv9Var3.b;
                    hv9Var = null;
                }
                if (animatorCreateAnimator != null) {
                    cv9 cv9Var = this.mPropagation;
                    if (cv9Var != null) {
                        long jB = cv9Var.b(viewGroup, this, hv9Var3, hv9Var4);
                        sparseIntArray.put(this.mAnimators.size(), (int) jB);
                        jMin = Math.min(jB, jMin);
                    }
                    String name = getName();
                    ima imaVar = dma.a;
                    jqa jqaVar = new jqa(viewGroup);
                    c cVar2 = new c();
                    cVar2.a = view;
                    cVar2.b = name;
                    cVar2.c = hv9Var;
                    cVar2.d = jqaVar;
                    cVar2.e = this;
                    tsVarC.put(animatorCreateAnimator, cVar2);
                    this.mAnimators.add(animatorCreateAnimator);
                }
            } else {
                i = size;
                i2 = i4;
            }
            i4 = i2 + 1;
            size = i;
        }
        if (sparseIntArray.size() != 0) {
            for (int i8 = 0; i8 < sparseIntArray.size(); i8++) {
                Animator animator2 = this.mAnimators.get(sparseIntArray.keyAt(i8));
                animator2.setStartDelay(animator2.getStartDelay() + (((long) sparseIntArray.valueAt(i8)) - jMin));
            }
        }
    }

    @m38
    public void end() {
        int i = this.mNumInstances - 1;
        this.mNumInstances = i;
        if (i == 0) {
            ArrayList<g> arrayList = this.mListeners;
            if (arrayList != null && arrayList.size() > 0) {
                ArrayList arrayList2 = (ArrayList) this.mListeners.clone();
                int size = arrayList2.size();
                for (int i2 = 0; i2 < size; i2++) {
                    ((g) arrayList2.get(i2)).onTransitionEnd(this);
                }
            }
            for (int i3 = 0; i3 < this.mStartValues.c.h(); i3++) {
                View view = (View) this.mStartValues.c.i(i3);
                if (view != null) {
                    WeakHashMap weakHashMap = sia.a;
                    view.setHasTransientState(false);
                }
            }
            for (int i4 = 0; i4 < this.mEndValues.c.h(); i4++) {
                View view2 = (View) this.mEndValues.c.i(i4);
                if (view2 != null) {
                    WeakHashMap weakHashMap2 = sia.a;
                    view2.setHasTransientState(false);
                }
            }
            this.mEnded = true;
        }
    }

    @vo6
    public au9 excludeChildren(@vo6 View view, boolean z) {
        ArrayList<View> arrayListA = this.mTargetChildExcludes;
        if (view != null) {
            arrayListA = z ? d.a(view, arrayListA) : d.b(view, arrayListA);
        }
        this.mTargetChildExcludes = arrayListA;
        return this;
    }

    @vo6
    public au9 excludeTarget(@vo6 View view, boolean z) {
        ArrayList<View> arrayListA = this.mTargetExcludes;
        if (view != null) {
            arrayListA = z ? d.a(view, arrayListA) : d.b(view, arrayListA);
        }
        this.mTargetExcludes = arrayListA;
        return this;
    }

    @m38
    public void forceToEnd(ViewGroup viewGroup) {
        ts tsVarC = c();
        int i = tsVarC.c;
        if (viewGroup == null || i == 0) {
            return;
        }
        ima imaVar = dma.a;
        jqa jqaVar = new jqa(viewGroup);
        ts tsVar = new ts(tsVarC);
        tsVarC.clear();
        for (int i2 = i - 1; i2 >= 0; i2--) {
            c cVar = (c) tsVar.j(i2);
            if (cVar.a != null && jqaVar.equals(cVar.d)) {
                ((Animator) tsVar.f(i2)).end();
            }
        }
    }

    public long getDuration() {
        return this.mDuration;
    }

    @rq6
    public Rect getEpicenter() {
        e eVar = this.mEpicenterCallback;
        if (eVar == null) {
            return null;
        }
        return eVar.a();
    }

    @rq6
    public e getEpicenterCallback() {
        return this.mEpicenterCallback;
    }

    @rq6
    public TimeInterpolator getInterpolator() {
        return this.mInterpolator;
    }

    /* JADX WARN: Code restructure failed: missing block: B:22:0x002d, code lost:
    
        if (r3 < 0) goto L28;
     */
    /* JADX WARN: Code restructure failed: missing block: B:23:0x002f, code lost:
    
        if (r7 == false) goto L25;
     */
    /* JADX WARN: Code restructure failed: missing block: B:24:0x0031, code lost:
    
        r6 = r5.mEndValuesList;
     */
    /* JADX WARN: Code restructure failed: missing block: B:25:0x0034, code lost:
    
        r6 = r5.mStartValuesList;
     */
    /* JADX WARN: Code restructure failed: missing block: B:27:0x003c, code lost:
    
        return r6.get(r3);
     */
    /* JADX WARN: Code restructure failed: missing block: B:28:0x003d, code lost:
    
        return null;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public hv9 getMatchedTransitionValues(View view, boolean z) {
        fv9 fv9Var = this.mParent;
        if (fv9Var != null) {
            return fv9Var.getMatchedTransitionValues(view, z);
        }
        ArrayList<hv9> arrayList = z ? this.mStartValuesList : this.mEndValuesList;
        if (arrayList == null) {
            return null;
        }
        int size = arrayList.size();
        int i = 0;
        while (true) {
            if (i >= size) {
                i = -1;
                break;
            }
            hv9 hv9Var = arrayList.get(i);
            if (hv9Var == null) {
                return null;
            }
            if (hv9Var.b == view) {
                break;
            }
            i++;
        }
    }

    @vo6
    public String getName() {
        return this.mName;
    }

    @vo6
    public h47 getPathMotion() {
        return this.mPathMotion;
    }

    @rq6
    public cv9 getPropagation() {
        return this.mPropagation;
    }

    public long getStartDelay() {
        return this.mStartDelay;
    }

    @vo6
    public List<Integer> getTargetIds() {
        return this.mTargetIds;
    }

    @rq6
    public List<String> getTargetNames() {
        return this.mTargetNames;
    }

    @rq6
    public List<Class<?>> getTargetTypes() {
        return this.mTargetTypes;
    }

    @vo6
    public List<View> getTargets() {
        return this.mTargets;
    }

    @rq6
    public String[] getTransitionProperties() {
        return null;
    }

    @rq6
    public hv9 getTransitionValues(@vo6 View view, boolean z) {
        fv9 fv9Var = this.mParent;
        if (fv9Var != null) {
            return fv9Var.getTransitionValues(view, z);
        }
        return (hv9) (z ? this.mStartValues : this.mEndValues).a.get(view);
    }

    public boolean isTransitionRequired(@rq6 hv9 hv9Var, @rq6 hv9 hv9Var2) {
        if (hv9Var != null && hv9Var2 != null) {
            String[] transitionProperties = getTransitionProperties();
            if (transitionProperties != null) {
                for (String str : transitionProperties) {
                    if (d(hv9Var, hv9Var2, str)) {
                        return true;
                    }
                }
            } else {
                Iterator it = hv9Var.a.keySet().iterator();
                while (it.hasNext()) {
                    if (d(hv9Var, hv9Var2, (String) it.next())) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public boolean isValidTarget(View view) {
        ArrayList<Class<?>> arrayList;
        ArrayList<String> arrayList2;
        int id = view.getId();
        ArrayList<Integer> arrayList3 = this.mTargetIdExcludes;
        if (arrayList3 != null && arrayList3.contains(Integer.valueOf(id))) {
            return false;
        }
        ArrayList<View> arrayList4 = this.mTargetExcludes;
        if (arrayList4 != null && arrayList4.contains(view)) {
            return false;
        }
        ArrayList<Class<?>> arrayList5 = this.mTargetTypeExcludes;
        if (arrayList5 != null) {
            int size = arrayList5.size();
            for (int i = 0; i < size; i++) {
                if (this.mTargetTypeExcludes.get(i).isInstance(view)) {
                    return false;
                }
            }
        }
        if (this.mTargetNameExcludes != null && sia.m(view) != null && this.mTargetNameExcludes.contains(sia.m(view))) {
            return false;
        }
        if ((this.mTargetIds.size() == 0 && this.mTargets.size() == 0 && (((arrayList = this.mTargetTypes) == null || arrayList.isEmpty()) && ((arrayList2 = this.mTargetNames) == null || arrayList2.isEmpty()))) || this.mTargetIds.contains(Integer.valueOf(id)) || this.mTargets.contains(view)) {
            return true;
        }
        ArrayList<String> arrayList6 = this.mTargetNames;
        if (arrayList6 != null && arrayList6.contains(sia.m(view))) {
            return true;
        }
        if (this.mTargetTypes != null) {
            for (int i2 = 0; i2 < this.mTargetTypes.size(); i2++) {
                if (this.mTargetTypes.get(i2).isInstance(view)) {
                    return true;
                }
            }
        }
        return false;
    }

    @m38
    public void pause(View view) {
        if (this.mEnded) {
            return;
        }
        for (int size = this.mCurrentAnimators.size() - 1; size >= 0; size--) {
            this.mCurrentAnimators.get(size).pause();
        }
        ArrayList<g> arrayList = this.mListeners;
        if (arrayList != null && arrayList.size() > 0) {
            ArrayList arrayList2 = (ArrayList) this.mListeners.clone();
            int size2 = arrayList2.size();
            for (int i = 0; i < size2; i++) {
                ((g) arrayList2.get(i)).onTransitionPause(this);
            }
        }
        this.mPaused = true;
    }

    public void playTransition(ViewGroup viewGroup) {
        c cVar;
        View view;
        hv9 hv9Var;
        View view2;
        View view3;
        View view4;
        this.mStartValuesList = new ArrayList<>();
        this.mEndValuesList = new ArrayList<>();
        iv9 iv9Var = this.mStartValues;
        iv9 iv9Var2 = this.mEndValues;
        ts tsVar = new ts(iv9Var.a);
        ts tsVar2 = new ts(iv9Var2.a);
        int i = 0;
        while (true) {
            int[] iArr = this.mMatchOrder;
            if (i >= iArr.length) {
                break;
            }
            int i2 = iArr[i];
            if (i2 == 1) {
                for (int i3 = tsVar.c - 1; i3 >= 0; i3--) {
                    View view5 = (View) tsVar.f(i3);
                    if (view5 != null && isValidTarget(view5) && (hv9Var = (hv9) tsVar2.remove(view5)) != null && isValidTarget(hv9Var.b)) {
                        this.mStartValuesList.add((hv9) tsVar.h(i3));
                        this.mEndValuesList.add(hv9Var);
                    }
                }
            } else if (i2 == 2) {
                ts tsVar3 = iv9Var.d;
                ts tsVar4 = iv9Var2.d;
                int i4 = tsVar3.c;
                for (int i5 = 0; i5 < i4; i5++) {
                    View view6 = (View) tsVar3.j(i5);
                    if (view6 != null && isValidTarget(view6) && (view2 = (View) tsVar4.get(tsVar3.f(i5))) != null && isValidTarget(view2)) {
                        hv9 hv9Var2 = (hv9) tsVar.get(view6);
                        hv9 hv9Var3 = (hv9) tsVar2.get(view2);
                        if (hv9Var2 != null && hv9Var3 != null) {
                            this.mStartValuesList.add(hv9Var2);
                            this.mEndValuesList.add(hv9Var3);
                            tsVar.remove(view6);
                            tsVar2.remove(view2);
                        }
                    }
                }
            } else if (i2 == 3) {
                SparseArray sparseArray = iv9Var.b;
                SparseArray sparseArray2 = iv9Var2.b;
                int size = sparseArray.size();
                for (int i6 = 0; i6 < size; i6++) {
                    View view7 = (View) sparseArray.valueAt(i6);
                    if (view7 != null && isValidTarget(view7) && (view3 = (View) sparseArray2.get(sparseArray.keyAt(i6))) != null && isValidTarget(view3)) {
                        hv9 hv9Var4 = (hv9) tsVar.get(view7);
                        hv9 hv9Var5 = (hv9) tsVar2.get(view3);
                        if (hv9Var4 != null && hv9Var5 != null) {
                            this.mStartValuesList.add(hv9Var4);
                            this.mEndValuesList.add(hv9Var5);
                            tsVar.remove(view7);
                            tsVar2.remove(view3);
                        }
                    }
                }
            } else if (i2 == 4) {
                hj5 hj5Var = iv9Var.c;
                hj5 hj5Var2 = iv9Var2.c;
                int iH = hj5Var.h();
                for (int i7 = 0; i7 < iH; i7++) {
                    View view8 = (View) hj5Var.i(i7);
                    if (view8 != null && isValidTarget(view8) && (view4 = (View) hj5Var2.c(hj5Var.f(i7))) != null && isValidTarget(view4)) {
                        hv9 hv9Var6 = (hv9) tsVar.get(view8);
                        hv9 hv9Var7 = (hv9) tsVar2.get(view4);
                        if (hv9Var6 != null && hv9Var7 != null) {
                            this.mStartValuesList.add(hv9Var6);
                            this.mEndValuesList.add(hv9Var7);
                            tsVar.remove(view8);
                            tsVar2.remove(view4);
                        }
                    }
                }
            }
            i++;
        }
        for (int i8 = 0; i8 < tsVar.c; i8++) {
            hv9 hv9Var8 = (hv9) tsVar.j(i8);
            if (isValidTarget(hv9Var8.b)) {
                this.mStartValuesList.add(hv9Var8);
                this.mEndValuesList.add(null);
            }
        }
        for (int i9 = 0; i9 < tsVar2.c; i9++) {
            hv9 hv9Var9 = (hv9) tsVar2.j(i9);
            if (isValidTarget(hv9Var9.b)) {
                this.mEndValuesList.add(hv9Var9);
                this.mStartValuesList.add(null);
            }
        }
        ts tsVarC = c();
        int i10 = tsVarC.c;
        ima imaVar = dma.a;
        jqa jqaVar = new jqa(viewGroup);
        for (int i11 = i10 - 1; i11 >= 0; i11--) {
            Animator animator = (Animator) tsVarC.f(i11);
            if (animator != null && (cVar = (c) tsVarC.get(animator)) != null && (view = cVar.a) != null && jqaVar.equals(cVar.d)) {
                hv9 hv9Var10 = cVar.c;
                hv9 transitionValues = getTransitionValues(view, true);
                hv9 matchedTransitionValues = getMatchedTransitionValues(view, true);
                if (transitionValues == null && matchedTransitionValues == null) {
                    matchedTransitionValues = (hv9) this.mEndValues.a.get(view);
                }
                if ((transitionValues != null || matchedTransitionValues != null) && cVar.e.isTransitionRequired(hv9Var10, matchedTransitionValues)) {
                    if (animator.isRunning() || animator.isStarted()) {
                        animator.cancel();
                    } else {
                        tsVarC.remove(animator);
                    }
                }
            }
        }
        createAnimators(viewGroup, this.mStartValues, this.mEndValues, this.mStartValuesList, this.mEndValuesList);
        runAnimators();
    }

    @vo6
    public au9 removeListener(@vo6 g gVar) {
        ArrayList<g> arrayList = this.mListeners;
        if (arrayList != null) {
            arrayList.remove(gVar);
            if (this.mListeners.size() == 0) {
                this.mListeners = null;
            }
        }
        return this;
    }

    @vo6
    public au9 removeTarget(@vo6 View view) {
        this.mTargets.remove(view);
        return this;
    }

    @m38
    public void resume(View view) {
        if (this.mPaused) {
            if (!this.mEnded) {
                for (int size = this.mCurrentAnimators.size() - 1; size >= 0; size--) {
                    this.mCurrentAnimators.get(size).resume();
                }
                ArrayList<g> arrayList = this.mListeners;
                if (arrayList != null && arrayList.size() > 0) {
                    ArrayList arrayList2 = (ArrayList) this.mListeners.clone();
                    int size2 = arrayList2.size();
                    for (int i = 0; i < size2; i++) {
                        ((g) arrayList2.get(i)).onTransitionResume(this);
                    }
                }
            }
            this.mPaused = false;
        }
    }

    @m38
    public void runAnimators() {
        start();
        ts tsVarC = c();
        for (Animator animator : this.mAnimators) {
            if (tsVarC.containsKey(animator)) {
                start();
                if (animator != null) {
                    animator.addListener(new zt9(this, tsVarC));
                    animate(animator);
                }
            }
        }
        this.mAnimators.clear();
        end();
    }

    public void setCanRemoveViews(boolean z) {
        this.mCanRemoveViews = z;
    }

    @vo6
    public au9 setDuration(long j) {
        this.mDuration = j;
        return this;
    }

    public void setEpicenterCallback(@rq6 e eVar) {
        this.mEpicenterCallback = eVar;
    }

    @vo6
    public au9 setInterpolator(@rq6 TimeInterpolator timeInterpolator) {
        this.mInterpolator = timeInterpolator;
        return this;
    }

    public void setMatchOrder(int... iArr) {
        if (iArr == null || iArr.length == 0) {
            this.mMatchOrder = DEFAULT_MATCH_ORDER;
            return;
        }
        for (int i = 0; i < iArr.length; i++) {
            int i2 = iArr[i];
            if (i2 < 1 || i2 > 4) {
                throw new IllegalArgumentException("matches contains invalid value");
            }
            for (int i3 = 0; i3 < i; i3++) {
                if (iArr[i3] == i2) {
                    throw new IllegalArgumentException("matches contains a duplicate value");
                }
            }
        }
        this.mMatchOrder = (int[]) iArr.clone();
    }

    public void setPathMotion(@rq6 h47 h47Var) {
        if (h47Var == null) {
            this.mPathMotion = STRAIGHT_PATH_MOTION;
        } else {
            this.mPathMotion = h47Var;
        }
    }

    public void setPropagation(@rq6 cv9 cv9Var) {
        this.mPropagation = cv9Var;
    }

    @vo6
    public au9 setStartDelay(long j) {
        this.mStartDelay = j;
        return this;
    }

    @m38
    public void start() {
        if (this.mNumInstances == 0) {
            ArrayList<g> arrayList = this.mListeners;
            if (arrayList != null && arrayList.size() > 0) {
                ArrayList arrayList2 = (ArrayList) this.mListeners.clone();
                int size = arrayList2.size();
                for (int i = 0; i < size; i++) {
                    ((g) arrayList2.get(i)).onTransitionStart(this);
                }
            }
            this.mEnded = false;
        }
        this.mNumInstances++;
    }

    public String toString(String str) {
        StringBuilder sbQ = vw2.q(str);
        sbQ.append(getClass().getSimpleName());
        sbQ.append("@");
        sbQ.append(Integer.toHexString(hashCode()));
        sbQ.append(": ");
        String string = sbQ.toString();
        if (this.mDuration != -1) {
            string = n41.r(fi7.l(string, "dur("), this.mDuration, ") ");
        }
        if (this.mStartDelay != -1) {
            string = n41.r(fi7.l(string, "dly("), this.mStartDelay, ") ");
        }
        if (this.mInterpolator != null) {
            StringBuilder sbL = fi7.l(string, "interp(");
            sbL.append(this.mInterpolator);
            sbL.append(") ");
            string = sbL.toString();
        }
        if (this.mTargetIds.size() <= 0 && this.mTargets.size() <= 0) {
            return string;
        }
        String strK = vw2.k(string, "tgts(");
        if (this.mTargetIds.size() > 0) {
            for (int i = 0; i < this.mTargetIds.size(); i++) {
                if (i > 0) {
                    strK = vw2.k(strK, ", ");
                }
                StringBuilder sbQ2 = vw2.q(strK);
                sbQ2.append(this.mTargetIds.get(i));
                strK = sbQ2.toString();
            }
        }
        if (this.mTargets.size() > 0) {
            for (int i2 = 0; i2 < this.mTargets.size(); i2++) {
                if (i2 > 0) {
                    strK = vw2.k(strK, ", ");
                }
                StringBuilder sbQ3 = vw2.q(strK);
                sbQ3.append(this.mTargets.get(i2));
                strK = sbQ3.toString();
            }
        }
        return vw2.k(strK, ")");
    }

    @vo6
    public au9 addTarget(@sg4 int i) {
        if (i != 0) {
            this.mTargetIds.add(Integer.valueOf(i));
        }
        return this;
    }

    @Override // 
    /* JADX INFO: renamed from: clone, reason: merged with bridge method [inline-methods] */
    public au9 mo49clone() {
        try {
            au9 au9Var = (au9) super.clone();
            au9Var.mAnimators = new ArrayList<>();
            au9Var.mStartValues = new iv9();
            au9Var.mEndValues = new iv9();
            au9Var.mStartValuesList = null;
            au9Var.mEndValuesList = null;
            return au9Var;
        } catch (CloneNotSupportedException unused) {
            return null;
        }
    }

    @vo6
    public au9 removeTarget(@sg4 int i) {
        if (i != 0) {
            this.mTargetIds.remove(Integer.valueOf(i));
        }
        return this;
    }

    @vo6
    public au9 addTarget(@vo6 String str) {
        if (this.mTargetNames == null) {
            this.mTargetNames = new ArrayList<>();
        }
        this.mTargetNames.add(str);
        return this;
    }

    @vo6
    public au9 removeTarget(@vo6 String str) {
        ArrayList<String> arrayList = this.mTargetNames;
        if (arrayList != null) {
            arrayList.remove(str);
        }
        return this;
    }

    @vo6
    public au9 excludeChildren(@sg4 int i, boolean z) {
        ArrayList<Integer> arrayListB = this.mTargetIdChildExcludes;
        if (i > 0) {
            if (z) {
                arrayListB = d.a(Integer.valueOf(i), arrayListB);
            } else {
                arrayListB = d.b(Integer.valueOf(i), arrayListB);
            }
        }
        this.mTargetIdChildExcludes = arrayListB;
        return this;
    }

    @vo6
    public au9 excludeTarget(@sg4 int i, boolean z) {
        ArrayList<Integer> arrayListB = this.mTargetIdExcludes;
        if (i > 0) {
            if (z) {
                arrayListB = d.a(Integer.valueOf(i), arrayListB);
            } else {
                arrayListB = d.b(Integer.valueOf(i), arrayListB);
            }
        }
        this.mTargetIdExcludes = arrayListB;
        return this;
    }

    @vo6
    public au9 removeTarget(@vo6 Class<?> cls) {
        ArrayList<Class<?>> arrayList = this.mTargetTypes;
        if (arrayList != null) {
            arrayList.remove(cls);
        }
        return this;
    }

    @vo6
    public au9 addTarget(@vo6 Class<?> cls) {
        if (this.mTargetTypes == null) {
            this.mTargetTypes = new ArrayList<>();
        }
        this.mTargetTypes.add(cls);
        return this;
    }

    @vo6
    public au9 excludeChildren(@vo6 Class<?> cls, boolean z) {
        ArrayList<Class<?>> arrayListB = this.mTargetTypeChildExcludes;
        if (cls != null) {
            if (z) {
                arrayListB = d.a(cls, arrayListB);
            } else {
                arrayListB = d.b(cls, arrayListB);
            }
        }
        this.mTargetTypeChildExcludes = arrayListB;
        return this;
    }

    @vo6
    public au9 excludeTarget(@vo6 String str, boolean z) {
        ArrayList<String> arrayListB = this.mTargetNameExcludes;
        if (str != null) {
            if (z) {
                arrayListB = d.a(str, arrayListB);
            } else {
                arrayListB = d.b(str, arrayListB);
            }
        }
        this.mTargetNameExcludes = arrayListB;
        return this;
    }

    @vo6
    public au9 excludeTarget(@vo6 Class<?> cls, boolean z) {
        ArrayList<Class<?>> arrayListB = this.mTargetTypeExcludes;
        if (cls != null) {
            if (z) {
                arrayListB = d.a(cls, arrayListB);
            } else {
                arrayListB = d.b(cls, arrayListB);
            }
        }
        this.mTargetTypeExcludes = arrayListB;
        return this;
    }

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