package ῲ.ⁱ.K.ῲ;

import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.RectF;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.util.Xml;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AnimationUtils;
import android.view.animation.AnticipateInterpolator;
import android.view.animation.BounceInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import androidx.constraintlayout.motion.widget.MotionLayout;
import androidx.constraintlayout.widget.R$id;
import androidx.constraintlayout.widget.R$styleable;
import androidx.recyclerview.widget.RecyclerView;
import com.adjust.sdk.Constants;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import ඓ.K.K.K.C1293;
import ῲ.ⁱ.ʬ.C2059;
import ῲ.ⁱ.ʬ.C2068;
import ῲ.ⁱ.K.K.C2184;
import K.K.K.ʬ.C2369;

/* renamed from: ῲ.ⁱ.K.ῲ.ᓣ  reason: contains not printable characters */
/* compiled from: MotionScene */
public class C2131 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public C2132 f7407 = null;

    /* renamed from: Ԕ  reason: contains not printable characters */
    public MotionEvent f7408;

    /* renamed from: ؿ  reason: contains not printable characters */
    public boolean f7409 = false;

    /* renamed from: ݜ  reason: contains not printable characters */
    public float f7410;

    /* renamed from: ඓ  reason: contains not printable characters */
    public ArrayList<C2132> f7411 = new ArrayList<>();

    /* renamed from: ᓣ  reason: contains not printable characters */
    public MotionLayout.AbstractC0127 f7412;

    /* renamed from: ᕣ  reason: contains not printable characters */
    public boolean f7413 = false;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public HashMap<String, Integer> f7414 = new HashMap<>();

    /* renamed from: ῲ  reason: contains not printable characters */
    public C2068 f7415 = null;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public ArrayList<C2132> f7416 = new ArrayList<>();

    /* renamed from: K  reason: contains not printable characters */
    public final MotionLayout f7417;

    /* renamed from: 㑃  reason: contains not printable characters */
    public int f7418 = Constants.MINIMAL_ERROR_STATUS_CODE;

    /* renamed from: 㗗  reason: contains not printable characters */
    public boolean f7419 = false;

    /* renamed from: 㗽  reason: contains not printable characters */
    public boolean f7420;

    /* renamed from: 㳳  reason: contains not printable characters */
    public SparseIntArray f7421 = new SparseIntArray();

    /* renamed from: 㴹  reason: contains not printable characters */
    public C2132 f7422 = null;

    /* renamed from: 㸾  reason: contains not printable characters */
    public boolean f7423 = false;

    /* renamed from: 㿎  reason: contains not printable characters */
    public SparseArray<C2059> f7424 = new SparseArray<>();

    /* renamed from: 䀟  reason: contains not printable characters */
    public float f7425;

    /* renamed from: 䁗  reason: contains not printable characters */
    public int f7426 = 0;

    /* renamed from: ῲ.ⁱ.K.ῲ.ᓣ$K  reason: contains not printable characters */
    /* compiled from: MotionScene */
    public class animation.InterpolatorC2134 implements Interpolator {

        /* renamed from: K  reason: contains not printable characters */
        public final /* synthetic */ C2184 f7448;

        public animation.InterpolatorC2134(C2131 r1, C2184 r2) {
            this.f7448 = r2;
        }

        public float getInterpolation(float f) {
            return (float) this.f7448.m5723((double) f);
        }
    }

    /* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARNING: Code restructure failed: missing block: B:28:0x00a9, code lost:
        if (r2.equals(ῲ.ᓆ.AbstractC1647.LOG_TAG) != false) goto L_0x00c1;
     */
    public C2131(Context context, MotionLayout motionLayout, int i) {
        C2132 r0 = null;
        this.f7417 = motionLayout;
        XmlResourceParser xml = context.getResources().getXml(i);
        try {
            int eventType = xml.getEventType();
            while (true) {
                char c = 1;
                if (eventType != 1) {
                    if (eventType == 0) {
                        xml.getName();
                    } else if (eventType == 2) {
                        String name = xml.getName();
                        if (this.f7413) {
                            PrintStream printStream = System.out;
                            printStream.println("parsing = " + name);
                        }
                        switch (name.hashCode()) {
                            case -1349929691:
                                if (name.equals("ConstraintSet")) {
                                    c = 5;
                                    break;
                                }
                                c = 65535;
                                break;
                            case -1239391468:
                                if (name.equals("KeyFrameSet")) {
                                    c = 6;
                                    break;
                                }
                                c = 65535;
                                break;
                            case 269306229:
                                break;
                            case 312750793:
                                if (name.equals("OnClick")) {
                                    c = 3;
                                    break;
                                }
                                c = 65535;
                                break;
                            case 327855227:
                                if (name.equals("OnSwipe")) {
                                    c = 2;
                                    break;
                                }
                                c = 65535;
                                break;
                            case 793277014:
                                if (name.equals("MotionScene")) {
                                    c = 0;
                                    break;
                                }
                                c = 65535;
                                break;
                            case 1382829617:
                                if (name.equals("StateSet")) {
                                    c = 4;
                                    break;
                                }
                                c = 65535;
                                break;
                            default:
                                c = 65535;
                                break;
                        }
                        switch (c) {
                            case 0:
                                m5631(context, xml);
                                continue;
                            case 1:
                                ArrayList<C2132> arrayList = this.f7411;
                                C2132 r2 = new C2132(this, context, xml);
                                arrayList.add(r2);
                                if (this.f7407 == null && !r2.f7434) {
                                    this.f7407 = r2;
                                    if (!(this.f7407 == null || this.f7407.f7437 == null)) {
                                        this.f7407.f7437.m5625(this.f7420);
                                    }
                                }
                                if (r2.f7434) {
                                    if (r2.f7427 == -1) {
                                        this.f7422 = r2;
                                    } else {
                                        this.f7416.add(r2);
                                    }
                                    this.f7411.remove(r2);
                                }
                                r0 = r2;
                                continue;
                            case 2:
                                if (r0 == null) {
                                    String resourceEntryName = context.getResources().getResourceEntryName(i);
                                    int lineNumber = xml.getLineNumber();
                                    Log.v("MotionScene", " OnSwipe (" + resourceEntryName + ".xml:" + lineNumber + ")");
                                }
                                r0.f7437 = new C2130(context, this.f7417, xml);
                                continue;
                            case 3:
                                r0.f7444.add(new C2132.View$OnClickListenerC2133(context, r0, xml));
                                continue;
                            case 4:
                                this.f7415 = new C2068(context, xml);
                                continue;
                            case 5:
                                m5637(context, xml);
                                continue;
                            case 6:
                                r0.f7432.add(new C2168(context, xml));
                                continue;
                            default:
                                Log.v("MotionScene", "WARNING UNKNOWN ATTRIBUTE " + name);
                                continue;
                        }
                    }
                    eventType = xml.next();
                } else {
                    this.f7424.put(R$id.motion_base, new C2059());
                    this.f7414.put("motion_base", Integer.valueOf(R$id.motion_base));
                    return;
                }
            }
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public int m5627() {
        C2132 r0 = this.f7407;
        if (r0 == null) {
            return -1;
        }
        return r0.f7427;
    }

    /* renamed from: ඓ  reason: contains not printable characters */
    public float m5628() {
        C2130 r0;
        C2132 r02 = this.f7407;
        if (r02 == null || (r0 = r02.f7437) == null) {
            return 0.0f;
        }
        return r0.f7392;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public final void m5631(Context context, XmlPullParser xmlPullParser) {
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlPullParser), R$styleable.MotionScene);
        int indexCount = obtainStyledAttributes.getIndexCount();
        for (int i = 0; i < indexCount; i++) {
            int index = obtainStyledAttributes.getIndex(i);
            if (index == R$styleable.MotionScene_defaultDuration) {
                this.f7418 = obtainStyledAttributes.getInt(index, this.f7418);
            } else if (index == R$styleable.MotionScene_layoutDuringTransition) {
                this.f7426 = obtainStyledAttributes.getInteger(index, 0);
            }
        }
        obtainStyledAttributes.recycle();
    }

    /* renamed from: ⁱ  reason: contains not printable characters */
    public int m5632() {
        C2132 r0 = this.f7407;
        if (r0 == null) {
            return -1;
        }
        return r0.f7442;
    }

    /* renamed from: 㴹  reason: contains not printable characters */
    public float m5643() {
        C2132 r0 = this.f7407;
        if (r0 != null) {
            return r0.f7433;
        }
        return 0.0f;
    }

    /* renamed from: 㸾  reason: contains not printable characters */
    public Interpolator m5644() {
        C2132 r0 = this.f7407;
        switch (r0.f7430) {
            case -2:
                return AnimationUtils.loadInterpolator(this.f7417.getContext(), this.f7407.f7435);
            case -1:
                return new animation.InterpolatorC2134(this, C2184.m5721(r0.f7441));
            case 0:
                return new AccelerateDecelerateInterpolator();
            case 1:
                return new AccelerateInterpolator();
            case 2:
                return new DecelerateInterpolator();
            case 3:
                return null;
            case 4:
                return new AnticipateInterpolator();
            case 5:
                return new BounceInterpolator();
            default:
                return null;
        }
    }

    /* renamed from: 㿎  reason: contains not printable characters */
    public boolean m5645() {
        Iterator<C2132> it2 = this.f7411.iterator();
        while (it2.hasNext()) {
            if (it2.next().f7437 != null) {
                return true;
            }
        }
        C2132 r0 = this.f7407;
        if (r0 == null || r0.f7437 == null) {
            return false;
        }
        return true;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:6:0x0013, code lost:
        if (r2 != -1) goto L_0x0018;
     */
    /* renamed from: K  reason: contains not printable characters */
    public void m5636(int i, int i2) {
        int i3;
        int i4;
        C2130 r7;
        C2068 r0 = this.f7415;
        if (r0 != null) {
            i4 = r0.m5395(i, -1, -1);
            if (i4 == -1) {
                i4 = i;
            }
            i3 = this.f7415.m5395(i2, -1, -1);
        } else {
            i4 = i;
        }
        i3 = i2;
        Iterator<C2132> it2 = this.f7411.iterator();
        while (it2.hasNext()) {
            C2132 next = it2.next();
            if ((next.f7427 == i3 && next.f7442 == i4) || (next.f7427 == i2 && next.f7442 == i)) {
                this.f7407 = next;
                C2132 r72 = this.f7407;
                if (r72 != null && (r7 = r72.f7437) != null) {
                    r7.m5625(this.f7420);
                    return;
                }
                return;
            }
        }
        C2132 r73 = this.f7422;
        Iterator<C2132> it3 = this.f7416.iterator();
        while (it3.hasNext()) {
            C2132 next2 = it3.next();
            if (next2.f7427 == i2) {
                r73 = next2;
            }
        }
        C2132 r8 = new C2132(this, r73);
        r8.f7442 = i4;
        r8.f7427 = i3;
        if (i4 != -1) {
            this.f7411.add(r8);
        }
        this.f7407 = r8;
    }

    /* renamed from: ῲ.ⁱ.K.ῲ.ᓣ$ῲ  reason: contains not printable characters */
    /* compiled from: MotionScene */
    public static class C2132 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public int f7427 = -1;

        /* renamed from: Ԕ  reason: contains not printable characters */
        public int f7428 = 0;

        /* renamed from: ؿ  reason: contains not printable characters */
        public int f7429 = -1;

        /* renamed from: ඓ  reason: contains not printable characters */
        public int f7430 = 0;

        /* renamed from: ᓣ  reason: contains not printable characters */
        public int f7431 = 0;

        /* renamed from: ᕣ  reason: contains not printable characters */
        public ArrayList<C2168> f7432 = new ArrayList<>();

        /* renamed from: ᨨ  reason: contains not printable characters */
        public float f7433 = 0.0f;

        /* renamed from: ῲ  reason: contains not printable characters */
        public boolean f7434 = false;

        /* renamed from: ⁱ  reason: contains not printable characters */
        public int f7435 = -1;

        /* renamed from: K  reason: contains not printable characters */
        public int f7436 = -1;

        /* renamed from: 㑃  reason: contains not printable characters */
        public C2130 f7437 = null;

        /* renamed from: 㗗  reason: contains not printable characters */
        public boolean f7438 = false;

        /* renamed from: 㗽  reason: contains not printable characters */
        public int f7439 = 0;

        /* renamed from: 㳳  reason: contains not printable characters */
        public final C2131 f7440;

        /* renamed from: 㴹  reason: contains not printable characters */
        public String f7441 = null;

        /* renamed from: 㸾  reason: contains not printable characters */
        public int f7442 = -1;

        /* renamed from: 㿎  reason: contains not printable characters */
        public int f7443 = Constants.MINIMAL_ERROR_STATUS_CODE;

        /* renamed from: 䁗  reason: contains not printable characters */
        public ArrayList<View$OnClickListenerC2133> f7444 = new ArrayList<>();

        public C2132(C2131 r5, C2132 r6) {
            this.f7440 = r5;
            if (r6 != null) {
                this.f7429 = r6.f7429;
                this.f7430 = r6.f7430;
                this.f7441 = r6.f7441;
                this.f7435 = r6.f7435;
                this.f7443 = r6.f7443;
                this.f7432 = r6.f7432;
                this.f7433 = r6.f7433;
                this.f7431 = r6.f7431;
            }
        }

        /* renamed from: ῲ.ⁱ.K.ῲ.ᓣ$ῲ$K  reason: contains not printable characters */
        /* compiled from: MotionScene */
        public static class View$OnClickListenerC2133 implements View.OnClickListener {

            /* renamed from: ʬ  reason: contains not printable characters */
            public int f7445 = -1;

            /* renamed from: ῲ  reason: contains not printable characters */
            public final C2132 f7446;

            /* renamed from: 㸾  reason: contains not printable characters */
            public int f7447 = 17;

            public View$OnClickListenerC2133(Context context, C2132 r4, XmlPullParser xmlPullParser) {
                this.f7446 = r4;
                TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlPullParser), R$styleable.OnClick);
                int indexCount = obtainStyledAttributes.getIndexCount();
                for (int i = 0; i < indexCount; i++) {
                    int index = obtainStyledAttributes.getIndex(i);
                    if (index == R$styleable.OnClick_targetId) {
                        this.f7445 = obtainStyledAttributes.getResourceId(index, this.f7445);
                    } else if (index == R$styleable.OnClick_clickAction) {
                        this.f7447 = obtainStyledAttributes.getInt(index, this.f7447);
                    }
                }
                obtainStyledAttributes.recycle();
            }

            public void onClick(View view) {
                MotionLayout motionLayout = this.f7446.f7440.f7417;
                if (motionLayout.m405()) {
                    C2132 r0 = this.f7446;
                    if (r0.f7442 == -1) {
                        int currentState = motionLayout.getCurrentState();
                        if (currentState == -1) {
                            motionLayout.m409(this.f7446.f7427);
                            return;
                        }
                        C2132 r2 = this.f7446;
                        C2132 r1 = new C2132(r2.f7440, r2);
                        r1.f7442 = currentState;
                        r1.f7427 = this.f7446.f7427;
                        motionLayout.setTransition(r1);
                        motionLayout.m426();
                        return;
                    }
                    C2132 r02 = r0.f7440.f7407;
                    int i = this.f7447;
                    boolean z = false;
                    boolean z2 = ((i & 1) == 0 && (i & 256) == 0) ? false : true;
                    int i2 = this.f7447;
                    boolean z3 = ((i2 & 16) == 0 && (i2 & RecyclerView.AbstractC0269.FLAG_APPEARED_IN_PRE_LAYOUT) == 0) ? false : true;
                    if (z2 && z3) {
                        C2132 r6 = this.f7446;
                        if (r6.f7440.f7407 != r6) {
                            motionLayout.setTransition(r6);
                        }
                        if (motionLayout.getCurrentState() == motionLayout.getEndState() || motionLayout.getProgress() > 0.5f) {
                            z2 = false;
                        } else {
                            z3 = false;
                        }
                    }
                    C2132 r62 = this.f7446;
                    if (r62 != r02) {
                        int i3 = r62.f7427;
                        int i4 = r62.f7442;
                        if (i4 != -1) {
                        }
                    }
                    z = true;
                    if (!z) {
                        return;
                    }
                    if (z2 && (this.f7447 & 1) != 0) {
                        motionLayout.setTransition(this.f7446);
                        motionLayout.m426();
                    } else if (z3 && (this.f7447 & 16) != 0) {
                        motionLayout.setTransition(this.f7446);
                        motionLayout.m407();
                    } else if (z2 && (this.f7447 & 256) != 0) {
                        motionLayout.setTransition(this.f7446);
                        motionLayout.setProgress(1.0f);
                    } else if (z3 && (this.f7447 & RecyclerView.AbstractC0269.FLAG_APPEARED_IN_PRE_LAYOUT) != 0) {
                        motionLayout.setTransition(this.f7446);
                        motionLayout.setProgress(0.0f);
                    }
                }
            }

            /* JADX WARN: Multi-variable type inference failed */
            /* JADX WARN: Type inference failed for: r5v5, types: [android.view.View] */
            /* JADX WARNING: Unknown variable types count: 1 */
            /* renamed from: K  reason: contains not printable characters */
            public void m5648(MotionLayout motionLayout, int i, C2132 r7) {
                int i2 = this.f7445;
                MotionLayout motionLayout2 = motionLayout;
                if (i2 != -1) {
                    motionLayout2 = motionLayout.findViewById(i2);
                }
                if (motionLayout2 == null) {
                    StringBuilder r5 = C1293.m3416("OnClick could not find id ");
                    r5.append(this.f7445);
                    Log.e("MotionScene", r5.toString());
                    return;
                }
                int i3 = r7.f7442;
                int i4 = r7.f7427;
                if (i3 == -1) {
                    motionLayout2.setOnClickListener(this);
                    return;
                }
                boolean z = true;
                boolean z2 = ((this.f7447 & 1) != 0 && i == i3) | ((this.f7447 & 1) != 0 && i == i3) | ((this.f7447 & 256) != 0 && i == i3) | ((this.f7447 & 16) != 0 && i == i4);
                if ((this.f7447 & RecyclerView.AbstractC0269.FLAG_APPEARED_IN_PRE_LAYOUT) == 0 || i != i4) {
                    z = false;
                }
                if (z2 || z) {
                    motionLayout2.setOnClickListener(this);
                }
            }

            /* renamed from: K  reason: contains not printable characters */
            public void m5647(MotionLayout motionLayout) {
                int i = this.f7445;
                if (i != -1) {
                    View findViewById = motionLayout.findViewById(i);
                    if (findViewById == null) {
                        StringBuilder r3 = C1293.m3416(" (*)  could not find id ");
                        r3.append(this.f7445);
                        Log.e("MotionScene", r3.toString());
                        return;
                    }
                    findViewById.setOnClickListener(null);
                }
            }
        }

        public C2132(C2131 r9, Context context, XmlPullParser xmlPullParser) {
            this.f7443 = r9.f7418;
            this.f7431 = r9.f7426;
            this.f7440 = r9;
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlPullParser), R$styleable.Transition);
            int indexCount = obtainStyledAttributes.getIndexCount();
            for (int i = 0; i < indexCount; i++) {
                int index = obtainStyledAttributes.getIndex(i);
                if (index == R$styleable.Transition_constraintSetEnd) {
                    this.f7427 = obtainStyledAttributes.getResourceId(index, this.f7427);
                    if ("layout".equals(context.getResources().getResourceTypeName(this.f7427))) {
                        C2059 r4 = new C2059();
                        r4.m5367(context, this.f7427);
                        r9.f7424.append(this.f7427, r4);
                    }
                } else if (index == R$styleable.Transition_constraintSetStart) {
                    this.f7442 = obtainStyledAttributes.getResourceId(index, this.f7442);
                    if ("layout".equals(context.getResources().getResourceTypeName(this.f7442))) {
                        C2059 r42 = new C2059();
                        r42.m5367(context, this.f7442);
                        r9.f7424.append(this.f7442, r42);
                    }
                } else if (index == R$styleable.Transition_motionInterpolator) {
                    int i2 = obtainStyledAttributes.peekValue(index).type;
                    if (i2 == 1) {
                        this.f7435 = obtainStyledAttributes.getResourceId(index, -1);
                        if (this.f7435 != -1) {
                            this.f7430 = -2;
                        }
                    } else if (i2 == 3) {
                        this.f7441 = obtainStyledAttributes.getString(index);
                        if (this.f7441.indexOf(com.appsflyer.share.Constants.URL_PATH_DELIMITER) > 0) {
                            this.f7435 = obtainStyledAttributes.getResourceId(index, -1);
                            this.f7430 = -2;
                        } else {
                            this.f7430 = -1;
                        }
                    } else {
                        this.f7430 = obtainStyledAttributes.getInteger(index, this.f7430);
                    }
                } else if (index == R$styleable.Transition_duration) {
                    this.f7443 = obtainStyledAttributes.getInt(index, this.f7443);
                } else if (index == R$styleable.Transition_staggered) {
                    this.f7433 = obtainStyledAttributes.getFloat(index, this.f7433);
                } else if (index == R$styleable.Transition_autoTransition) {
                    this.f7428 = obtainStyledAttributes.getInteger(index, this.f7428);
                } else if (index == R$styleable.Transition_android_id) {
                    this.f7436 = obtainStyledAttributes.getResourceId(index, this.f7436);
                } else if (index == R$styleable.Transition_transitionDisable) {
                    this.f7438 = obtainStyledAttributes.getBoolean(index, this.f7438);
                } else if (index == R$styleable.Transition_pathMotionArc) {
                    this.f7429 = obtainStyledAttributes.getInteger(index, -1);
                } else if (index == R$styleable.Transition_layoutDuringTransition) {
                    this.f7431 = obtainStyledAttributes.getInteger(index, 0);
                } else if (index == R$styleable.Transition_transitionFlags) {
                    this.f7439 = obtainStyledAttributes.getInteger(index, 0);
                }
            }
            if (this.f7442 == -1) {
                this.f7434 = true;
            }
            obtainStyledAttributes.recycle();
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public int m5629() {
        C2132 r0 = this.f7407;
        if (r0 != null) {
            return r0.f7443;
        }
        return this.f7418;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public final void m5630(int i) {
        int i2 = this.f7421.get(i);
        if (i2 > 0) {
            m5630(this.f7421.get(i));
            C2059 r1 = this.f7424.get(i);
            C2059 r2 = this.f7424.get(i2);
            if (r2 == null) {
                StringBuilder r4 = C1293.m3416("ERROR! invalid deriveConstraintsFrom: @id/");
                r4.append(C2369.m6314(this.f7417.getContext(), i2));
                Log.e("MotionScene", r4.toString());
                return;
            }
            r1.m5376(r2);
            this.f7421.put(i, -1);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public ArrayList<C2132> m5634() {
        return this.f7411;
    }

    /* renamed from: K  reason: contains not printable characters */
    public boolean m5642(MotionLayout motionLayout, int i) {
        int i2;
        if ((this.f7412 != null) || this.f7423) {
            return false;
        }
        Iterator<C2132> it2 = this.f7411.iterator();
        while (it2.hasNext()) {
            C2132 next = it2.next();
            int i3 = next.f7428;
            if (!(i3 == 0 || this.f7407 == next)) {
                if (i == next.f7442 && (i3 == 4 || i3 == 2)) {
                    motionLayout.setState(MotionLayout.TransitionState.FINISHED);
                    motionLayout.setTransition(next);
                    if (next.f7428 == 4) {
                        motionLayout.m426();
                        motionLayout.setState(MotionLayout.TransitionState.SETUP);
                        motionLayout.setState(MotionLayout.TransitionState.MOVING);
                    } else {
                        motionLayout.setProgress(1.0f);
                        motionLayout.m422(true);
                        motionLayout.setState(MotionLayout.TransitionState.SETUP);
                        motionLayout.setState(MotionLayout.TransitionState.MOVING);
                        motionLayout.setState(MotionLayout.TransitionState.FINISHED);
                        motionLayout.m406();
                    }
                    return true;
                } else if (i == next.f7427 && ((i2 = next.f7428) == 3 || i2 == 1)) {
                    motionLayout.setState(MotionLayout.TransitionState.FINISHED);
                    motionLayout.setTransition(next);
                    if (next.f7428 == 3) {
                        motionLayout.m407();
                        motionLayout.setState(MotionLayout.TransitionState.SETUP);
                        motionLayout.setState(MotionLayout.TransitionState.MOVING);
                    } else {
                        motionLayout.setProgress(0.0f);
                        motionLayout.m422(true);
                        motionLayout.setState(MotionLayout.TransitionState.SETUP);
                        motionLayout.setState(MotionLayout.TransitionState.MOVING);
                        motionLayout.setState(MotionLayout.TransitionState.FINISHED);
                        motionLayout.m406();
                    }
                    return true;
                }
            }
        }
        return false;
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m5641(boolean z) {
        C2130 r2;
        this.f7420 = z;
        C2132 r22 = this.f7407;
        if (r22 != null && (r2 = r22.f7437) != null) {
            r2.m5625(this.f7420);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public final int m5633(Context context, String str) {
        int i;
        if (str.contains(com.appsflyer.share.Constants.URL_PATH_DELIMITER)) {
            i = context.getResources().getIdentifier(str.substring(str.indexOf(47) + 1), "id", context.getPackageName());
            if (this.f7413) {
                PrintStream printStream = System.out;
                printStream.println("id getMap res = " + i);
            }
        } else {
            i = -1;
        }
        if (i != -1) {
            return i;
        }
        if (str.length() > 1) {
            return Integer.parseInt(str.substring(1));
        }
        Log.e("MotionScene", "error in parsing id");
        return i;
    }

    /* JADX WARNING: Removed duplicated region for block: B:17:0x005a  */
    /* JADX WARNING: Removed duplicated region for block: B:19:0x0062  */
    /* renamed from: K  reason: contains not printable characters */
    public final void m5637(Context context, XmlPullParser xmlPullParser) {
        char c;
        C2059 r0 = new C2059();
        r0.f7007 = false;
        int attributeCount = xmlPullParser.getAttributeCount();
        int i = -1;
        int i2 = -1;
        for (int i3 = 0; i3 < attributeCount; i3++) {
            String attributeName = xmlPullParser.getAttributeName(i3);
            String attributeValue = xmlPullParser.getAttributeValue(i3);
            if (this.f7413) {
                PrintStream printStream = System.out;
                printStream.println("id string = " + attributeValue);
            }
            int hashCode = attributeName.hashCode();
            if (hashCode != -1496482599) {
                if (hashCode == 3355 && attributeName.equals("id")) {
                    c = 0;
                    if (c == 0) {
                        i = m5633(context, attributeValue);
                        HashMap<String, Integer> hashMap = this.f7414;
                        int indexOf = attributeValue.indexOf(47);
                        if (indexOf >= 0) {
                            attributeValue = attributeValue.substring(indexOf + 1);
                        }
                        hashMap.put(attributeValue, Integer.valueOf(i));
                    } else if (c == 1) {
                        i2 = m5633(context, attributeValue);
                    }
                }
            } else if (attributeName.equals("deriveConstraintsFrom")) {
                c = 1;
                if (c == 0) {
                }
            }
            c = 65535;
            if (c == 0) {
            }
        }
        if (i != -1) {
            int i4 = this.f7417.f713;
            r0.m5372(context, xmlPullParser);
            if (i2 != -1) {
                this.f7421.put(i, i2);
            }
            this.f7424.put(i, r0);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public C2059 m5635(int i) {
        int r0;
        if (this.f7413) {
            PrintStream printStream = System.out;
            printStream.println("id " + i);
            PrintStream printStream2 = System.out;
            StringBuilder r1 = C1293.m3416("size ");
            r1.append(this.f7424.size());
            printStream2.println(r1.toString());
        }
        C2068 r02 = this.f7415;
        if (!(r02 == null || (r0 = r02.m5395(i, -1, -1)) == -1)) {
            i = r0;
        }
        if (this.f7424.get(i) != null) {
            return this.f7424.get(i);
        }
        StringBuilder r03 = C1293.m3416("Warning could not find ConstraintSet id/");
        r03.append(C2369.m6314(this.f7417.getContext(), i));
        r03.append(" In MotionScene");
        Log.e("MotionScene", r03.toString());
        SparseArray<C2059> sparseArray = this.f7424;
        return sparseArray.get(sparseArray.keyAt(0));
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m5640(C2110 r3) {
        C2132 r0 = this.f7407;
        if (r0 == null) {
            C2132 r02 = this.f7422;
            if (r02 != null) {
                Iterator<C2168> it2 = r02.f7432.iterator();
                while (it2.hasNext()) {
                    it2.next().m5696(r3);
                }
                return;
            }
            return;
        }
        Iterator<C2168> it3 = r0.f7432.iterator();
        while (it3.hasNext()) {
            it3.next().m5696(r3);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m5638(MotionEvent motionEvent, int i, MotionLayout motionLayout) {
        MotionLayout.AbstractC0127 r1;
        C2130 r2;
        RectF rectF;
        View findViewById;
        MotionEvent motionEvent2;
        C2132 r13;
        int i2;
        C2130 r6;
        RectF r5;
        RectF rectF2 = new RectF();
        if (this.f7412 == null) {
            this.f7412 = this.f7417.m425();
        }
        VelocityTracker velocityTracker = ((MotionLayout.C0131) this.f7412).f780;
        if (velocityTracker != null) {
            velocityTracker.addMovement(motionEvent);
        }
        if (i != -1) {
            int action = motionEvent.getAction();
            if (action == 0) {
                this.f7410 = motionEvent.getRawX();
                this.f7425 = motionEvent.getRawY();
                this.f7408 = motionEvent;
                this.f7419 = false;
                C2130 r12 = this.f7407.f7437;
                if (r12 != null) {
                    MotionLayout motionLayout2 = this.f7417;
                    int i3 = r12.f7402;
                    if (i3 == -1 || (findViewById = motionLayout2.findViewById(i3)) == null) {
                        rectF = null;
                    } else {
                        rectF2.set((float) findViewById.getLeft(), (float) findViewById.getTop(), (float) findViewById.getRight(), (float) findViewById.getBottom());
                        rectF = rectF2;
                    }
                    if (rectF == null || rectF.contains(this.f7408.getX(), this.f7408.getY())) {
                        RectF r14 = this.f7407.f7437.m5623(this.f7417, rectF2);
                        if (r14 == null || r14.contains(this.f7408.getX(), this.f7408.getY())) {
                            this.f7409 = false;
                        } else {
                            this.f7409 = true;
                        }
                        C2130 r15 = this.f7407.f7437;
                        float f = this.f7410;
                        float f2 = this.f7425;
                        r15.f7406 = f;
                        r15.f7387 = f2;
                        return;
                    }
                    this.f7408 = null;
                    this.f7419 = true;
                    return;
                }
                return;
            } else if (action == 2 && !this.f7419) {
                float rawY = motionEvent.getRawY() - this.f7425;
                float rawX = motionEvent.getRawX() - this.f7410;
                if ((((double) rawX) != 0.0d || ((double) rawY) != 0.0d) && (motionEvent2 = this.f7408) != null) {
                    if (i != -1) {
                        C2068 r122 = this.f7415;
                        if (r122 == null || (i2 = r122.m5395(i, -1, -1)) == -1) {
                            i2 = i;
                        }
                        ArrayList<C2132> arrayList = new ArrayList();
                        Iterator<C2132> it2 = this.f7411.iterator();
                        while (it2.hasNext()) {
                            C2132 next = it2.next();
                            if (next.f7442 == i2 || next.f7427 == i2) {
                                arrayList.add(next);
                            }
                        }
                        RectF rectF3 = new RectF();
                        r13 = null;
                        float f3 = 0.0f;
                        for (C2132 r152 : arrayList) {
                            if (!r152.f7438 && (r6 = r152.f7437) != null) {
                                r6.m5625(this.f7420);
                                RectF r52 = r152.f7437.m5623(this.f7417, rectF3);
                                if ((r52 == null || r52.contains(motionEvent2.getX(), motionEvent2.getY())) && ((r5 = r152.f7437.m5623(this.f7417, rectF3)) == null || r5.contains(motionEvent2.getX(), motionEvent2.getY()))) {
                                    C2130 r53 = r152.f7437;
                                    float f4 = ((r53.f7401 * rawY) + (r53.f7394 * rawX)) * (r152.f7427 == i ? -1.0f : 1.1f);
                                    if (f4 > f3) {
                                        f3 = f4;
                                        r13 = r152;
                                    }
                                }
                            }
                        }
                    } else {
                        r13 = this.f7407;
                    }
                    if (r13 != null) {
                        motionLayout.setTransition(r13);
                        RectF r22 = this.f7407.f7437.m5623(this.f7417, rectF2);
                        this.f7409 = r22 != null && !r22.contains(this.f7408.getX(), this.f7408.getY());
                        C2130 r23 = this.f7407.f7437;
                        float f5 = this.f7410;
                        float f6 = this.f7425;
                        r23.f7406 = f5;
                        r23.f7387 = f6;
                        r23.f7393 = false;
                    }
                } else {
                    return;
                }
            }
        }
        if (!this.f7419) {
            C2132 r24 = this.f7407;
            if (!(r24 == null || (r2 = r24.f7437) == null || this.f7409)) {
                r2.m5624(motionEvent, this.f7412);
            }
            this.f7410 = motionEvent.getRawX();
            this.f7425 = motionEvent.getRawY();
            if (motionEvent.getAction() == 1 && (r1 = this.f7412) != null) {
                MotionLayout.C0131 r16 = (MotionLayout.C0131) r1;
                r16.f780.recycle();
                r16.f780 = null;
                this.f7412 = null;
                int i4 = motionLayout.f742;
                if (i4 != -1) {
                    m5642(motionLayout, i4);
                }
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m5639(MotionLayout motionLayout) {
        boolean z;
        for (int i = 0; i < this.f7424.size(); i++) {
            int keyAt = this.f7424.keyAt(i);
            int i2 = this.f7421.get(keyAt);
            int size = this.f7421.size();
            while (true) {
                z = true;
                if (i2 <= 0) {
                    z = false;
                    break;
                } else if (i2 == keyAt) {
                    break;
                } else {
                    int i3 = size - 1;
                    if (size < 0) {
                        break;
                    }
                    i2 = this.f7421.get(i2);
                    size = i3;
                }
            }
            if (z) {
                Log.e("MotionScene", "Cannot be derived from yourself");
                return;
            } else {
                m5630(keyAt);
            }
        }
        for (int i4 = 0; i4 < this.f7424.size(); i4++) {
            this.f7424.valueAt(i4).m5378(motionLayout);
        }
    }
}
