package d.f.b.a;

import android.content.Context;
import android.graphics.Canvas;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
import androidx.constraintlayout.widget.ConstraintLayout;
import d.f.b.a.d;
import d.f.c.c;
import d.h.j.o;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;

/* JADX INFO: loaded from: classes.dex */
public class c extends ConstraintLayout implements o {
    public static final /* synthetic */ int F = 0;
    public float G;
    public int H;
    public int I;
    public int J;
    public boolean K;
    public long L;
    public float M;
    public float N;
    public float O;
    public long P;
    public float Q;
    public InterfaceC0026c R;
    public int S;
    public d.f.b.a.a T;
    public long U;
    public boolean V;
    public ArrayList<d.f.b.a.b> W;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    public ArrayList<d.f.b.a.b> f2418a0;

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public CopyOnWriteArrayList<InterfaceC0026c> f2419b0;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    public int f2420c0;

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    public float f2421d0;
    public float e0;
    public boolean f0;
    public b g0;
    public boolean h0;
    public d i0;
    public boolean j0;

    public class a implements Runnable {
        public a() {
        }

        @Override // java.lang.Runnable
        public void run() {
            c.this.g0.a();
        }
    }

    public class b {
        public float a = Float.NaN;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public float f2423b = Float.NaN;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public int f2424c = -1;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public int f2425d = -1;

        public b() {
        }

        public void a() {
            int iA;
            d dVar = d.SETUP;
            int i2 = this.f2424c;
            if (i2 != -1 || this.f2425d != -1) {
                if (i2 == -1) {
                    c.this.x(this.f2425d);
                } else {
                    int i3 = this.f2425d;
                    if (i3 == -1) {
                        c cVar = c.this;
                        cVar.setState(dVar);
                        cVar.I = i2;
                        cVar.H = -1;
                        cVar.J = -1;
                        d.f.c.c cVar2 = cVar.f583w;
                        if (cVar2 != null) {
                            float f2 = -1;
                            int i4 = cVar2.f2447b;
                            if (i4 == i2) {
                                c.a aVarValueAt = i2 == -1 ? cVar2.f2449d.valueAt(0) : cVar2.f2449d.get(i4);
                                int i5 = cVar2.f2448c;
                                if ((i5 == -1 || !aVarValueAt.f2451b.get(i5).a(f2, f2)) && cVar2.f2448c != (iA = aVarValueAt.a(f2, f2))) {
                                    d.f.c.d dVar2 = iA == -1 ? null : aVarValueAt.f2451b.get(iA).f2458f;
                                    if (iA != -1) {
                                        int i6 = aVarValueAt.f2451b.get(iA).f2457e;
                                    }
                                    if (dVar2 != null) {
                                        cVar2.f2448c = iA;
                                        dVar2.a(cVar2.a);
                                    }
                                }
                            } else {
                                cVar2.f2447b = i2;
                                c.a aVar = cVar2.f2449d.get(i2);
                                int iA2 = aVar.a(f2, f2);
                                d.f.c.d dVar3 = iA2 == -1 ? aVar.f2453d : aVar.f2451b.get(iA2).f2458f;
                                if (iA2 != -1) {
                                    int i7 = aVar.f2451b.get(iA2).f2457e;
                                }
                                if (dVar3 == null) {
                                    Log.v("ConstraintLayoutStates", "NO Constraint set found ! id=" + i2 + ", dim =" + f2 + ", " + f2);
                                } else {
                                    cVar2.f2448c = iA2;
                                    dVar3.a(cVar2.a);
                                }
                            }
                        }
                    } else {
                        c.this.w(i2, i3);
                    }
                }
                c.this.setState(dVar);
            }
            if (Float.isNaN(this.f2423b)) {
                if (Float.isNaN(this.a)) {
                    return;
                }
                c.this.setProgress(this.a);
            } else {
                c.this.v(this.a, this.f2423b);
                this.a = Float.NaN;
                this.f2423b = Float.NaN;
                this.f2424c = -1;
                this.f2425d = -1;
            }
        }
    }

    /* JADX INFO: renamed from: d.f.b.a.c$c, reason: collision with other inner class name */
    public interface InterfaceC0026c {
        void a(c cVar, int i2, int i3, float f2);

        void b(c cVar, int i2, int i3);
    }

    public enum d {
        UNDEFINED,
        SETUP,
        MOVING,
        FINISHED
    }

    @Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewGroup, android.view.View
    public void dispatchDraw(Canvas canvas) {
        s(false);
        super.dispatchDraw(canvas);
    }

    public int[] getConstraintSetIds() {
        return null;
    }

    public int getCurrentState() {
        return this.I;
    }

    public ArrayList<d.a> getDefinedTransitions() {
        return null;
    }

    public d.f.b.a.a getDesignTool() {
        if (this.T == null) {
            this.T = new d.f.b.a.a(this);
        }
        return this.T;
    }

    public int getEndState() {
        return this.J;
    }

    public long getNanoTime() {
        return System.nanoTime();
    }

    public float getProgress() {
        return this.O;
    }

    public int getStartState() {
        return this.H;
    }

    public float getTargetPosition() {
        return this.Q;
    }

    public Bundle getTransitionState() {
        if (this.g0 == null) {
            this.g0 = new b();
        }
        b bVar = this.g0;
        c cVar = c.this;
        bVar.f2425d = cVar.J;
        bVar.f2424c = cVar.H;
        bVar.f2423b = cVar.getVelocity();
        bVar.a = c.this.getProgress();
        b bVar2 = this.g0;
        Objects.requireNonNull(bVar2);
        Bundle bundle = new Bundle();
        bundle.putFloat("motion.progress", bVar2.a);
        bundle.putFloat("motion.velocity", bVar2.f2423b);
        bundle.putInt("motion.StartState", bVar2.f2424c);
        bundle.putInt("motion.EndState", bVar2.f2425d);
        return bundle;
    }

    public long getTransitionTimeMs() {
        return (long) (this.M * 1000.0f);
    }

    public float getVelocity() {
        return this.G;
    }

    @Override // androidx.constraintlayout.widget.ConstraintLayout
    public void h(int i2) {
        this.f583w = null;
    }

    @Override // android.view.View
    public boolean isAttachedToWindow() {
        return super.isAttachedToWindow();
    }

    @Override // d.h.j.o
    public void j(View view, int i2, int i3, int i4, int i5, int i6, int[] iArr) {
        if (i2 == 0 && i3 == 0) {
            return;
        }
        iArr[0] = iArr[0] + i4;
        iArr[1] = iArr[1] + i5;
    }

    @Override // d.h.j.n
    public void k(View view, int i2, int i3, int i4, int i5, int i6) {
    }

    @Override // d.h.j.n
    public boolean l(View view, View view2, int i2, int i3) {
        return false;
    }

    @Override // d.h.j.n
    public void m(View view, View view2, int i2, int i3) {
        this.U = getNanoTime();
    }

    @Override // d.h.j.n
    public void n(View view, int i2) {
    }

    @Override // d.h.j.n
    public void o(View view, int i2, int i3, int[] iArr, int i4) {
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        Display display = getDisplay();
        if (display != null) {
            display.getRotation();
        }
        b bVar = this.g0;
        if (bVar != null) {
            if (this.h0) {
                post(new a());
            } else {
                bVar.a();
            }
        }
    }

    @Override // android.view.ViewGroup
    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        return false;
    }

    @Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewGroup, android.view.View
    public void onLayout(boolean z2, int i2, int i3, int i4, int i5) {
        this.f0 = true;
        try {
            super.onLayout(z2, i2, i3, i4, i5);
        } finally {
            this.f0 = false;
        }
    }

    @Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.View
    public void onMeasure(int i2, int i3) {
        super.onMeasure(i2, i3);
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public boolean onNestedFling(View view, float f2, float f3, boolean z2) {
        return false;
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public boolean onNestedPreFling(View view, float f2, float f3) {
        return false;
    }

    @Override // android.view.View
    public void onRtlPropertiesChanged(int i2) {
    }

    @Override // android.view.View
    public boolean onTouchEvent(MotionEvent motionEvent) {
        return super.onTouchEvent(motionEvent);
    }

    @Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewGroup
    public void onViewAdded(View view) {
        super.onViewAdded(view);
        if (view instanceof d.f.b.a.b) {
            d.f.b.a.b bVar = (d.f.b.a.b) view;
            if (this.f2419b0 == null) {
                this.f2419b0 = new CopyOnWriteArrayList<>();
            }
            this.f2419b0.add(bVar);
            if (bVar.f2414t) {
                if (this.W == null) {
                    this.W = new ArrayList<>();
                }
                this.W.add(bVar);
            }
            if (bVar.f2415u) {
                if (this.f2418a0 == null) {
                    this.f2418a0 = new ArrayList<>();
                }
                this.f2418a0.add(bVar);
            }
        }
    }

    @Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.ViewGroup
    public void onViewRemoved(View view) {
        super.onViewRemoved(view);
        ArrayList<d.f.b.a.b> arrayList = this.W;
        if (arrayList != null) {
            arrayList.remove(view);
        }
        ArrayList<d.f.b.a.b> arrayList2 = this.f2418a0;
        if (arrayList2 != null) {
            arrayList2.remove(view);
        }
    }

    @Override // androidx.constraintlayout.widget.ConstraintLayout, android.view.View, android.view.ViewParent
    public void requestLayout() {
        int i2 = this.I;
        super.requestLayout();
    }

    /* JADX WARN: Removed duplicated region for block: B:93:0x011c A[PHI: r2
      0x011c: PHI (r2v6 int) = (r2v4 int), (r2v7 int) binds: [B:91:0x0119, B:86:0x010e] A[DONT_GENERATE, DONT_INLINE]] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void s(boolean r18) {
        /*
            Method dump skipped, instruction units count: 311
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: d.f.b.a.c.s(boolean):void");
    }

    public void setDebugMode(int i2) {
        this.S = i2;
        invalidate();
    }

    public void setDelayedApplicationOfInitialState(boolean z2) {
        this.h0 = z2;
    }

    public void setInteractionEnabled(boolean z2) {
        this.K = z2;
    }

    public void setInterpolatedProgress(float f2) {
        setProgress(f2);
    }

    public void setOnHide(float f2) {
        ArrayList<d.f.b.a.b> arrayList = this.f2418a0;
        if (arrayList != null) {
            int size = arrayList.size();
            for (int i2 = 0; i2 < size; i2++) {
                this.f2418a0.get(i2).setProgress(f2);
            }
        }
    }

    public void setOnShow(float f2) {
        ArrayList<d.f.b.a.b> arrayList = this.W;
        if (arrayList != null) {
            int size = arrayList.size();
            for (int i2 = 0; i2 < size; i2++) {
                this.W.get(i2).setProgress(f2);
            }
        }
    }

    public void setProgress(float f2) {
        d dVar = d.FINISHED;
        d dVar2 = d.MOVING;
        if (f2 < 0.0f || f2 > 1.0f) {
            Log.w("MotionLayout", "Warning! Progress is defined for values between 0.0 and 1.0 inclusive");
        }
        if (!super.isAttachedToWindow()) {
            if (this.g0 == null) {
                this.g0 = new b();
            }
            this.g0.a = f2;
            return;
        }
        if (f2 <= 0.0f) {
            if (this.O == 1.0f && this.I == this.J) {
                setState(dVar2);
            }
            this.I = this.H;
            if (this.O != 0.0f) {
                return;
            }
        } else {
            if (f2 < 1.0f) {
                this.I = -1;
                setState(dVar2);
                return;
            }
            if (this.O == 0.0f && this.I == this.H) {
                setState(dVar2);
            }
            this.I = this.J;
            if (this.O != 1.0f) {
                return;
            }
        }
        setState(dVar);
    }

    public void setScene(d.f.b.a.d dVar) {
        g();
        throw null;
    }

    public void setStartState(int i2) {
        if (super.isAttachedToWindow()) {
            this.I = i2;
            return;
        }
        if (this.g0 == null) {
            this.g0 = new b();
        }
        b bVar = this.g0;
        bVar.f2424c = i2;
        bVar.f2425d = i2;
    }

    public void setState(d dVar) {
        d dVar2 = d.FINISHED;
        if (dVar == dVar2 && this.I == -1) {
            return;
        }
        d dVar3 = this.i0;
        this.i0 = dVar;
        d dVar4 = d.MOVING;
        if (dVar3 == dVar4 && dVar == dVar4) {
            t();
        }
        int iOrdinal = dVar3.ordinal();
        if (iOrdinal == 0 || iOrdinal == 1) {
            if (dVar == dVar4) {
                t();
            }
            if (dVar != dVar2) {
                return;
            }
        } else if (iOrdinal != 2 || dVar != dVar2) {
            return;
        }
        u();
    }

    public void setTransition(int i2) {
    }

    public void setTransition(d.a aVar) {
        throw null;
    }

    public void setTransitionDuration(int i2) {
        Log.e("MotionLayout", "MotionScene not defined");
    }

    public void setTransitionListener(InterfaceC0026c interfaceC0026c) {
        this.R = interfaceC0026c;
    }

    public void setTransitionState(Bundle bundle) {
        if (this.g0 == null) {
            this.g0 = new b();
        }
        b bVar = this.g0;
        Objects.requireNonNull(bVar);
        bVar.a = bundle.getFloat("motion.progress");
        bVar.f2423b = bundle.getFloat("motion.velocity");
        bVar.f2424c = bundle.getInt("motion.StartState");
        bVar.f2425d = bundle.getInt("motion.EndState");
        if (super.isAttachedToWindow()) {
            this.g0.a();
        }
    }

    public final void t() {
        CopyOnWriteArrayList<InterfaceC0026c> copyOnWriteArrayList;
        if ((this.R == null && ((copyOnWriteArrayList = this.f2419b0) == null || copyOnWriteArrayList.isEmpty())) || this.f2421d0 == this.N) {
            return;
        }
        if (this.f2420c0 != -1) {
            InterfaceC0026c interfaceC0026c = this.R;
            if (interfaceC0026c != null) {
                interfaceC0026c.b(this, this.H, this.J);
            }
            CopyOnWriteArrayList<InterfaceC0026c> copyOnWriteArrayList2 = this.f2419b0;
            if (copyOnWriteArrayList2 != null) {
                Iterator<InterfaceC0026c> it = copyOnWriteArrayList2.iterator();
                while (it.hasNext()) {
                    it.next().b(this, this.H, this.J);
                }
            }
        }
        this.f2420c0 = -1;
        float f2 = this.N;
        this.f2421d0 = f2;
        InterfaceC0026c interfaceC0026c2 = this.R;
        if (interfaceC0026c2 != null) {
            interfaceC0026c2.a(this, this.H, this.J, f2);
        }
        CopyOnWriteArrayList<InterfaceC0026c> copyOnWriteArrayList3 = this.f2419b0;
        if (copyOnWriteArrayList3 != null) {
            Iterator<InterfaceC0026c> it2 = copyOnWriteArrayList3.iterator();
            while (it2.hasNext()) {
                it2.next().a(this, this.H, this.J, this.N);
            }
        }
    }

    @Override // android.view.View
    public String toString() {
        Context context = getContext();
        return d.b.a.d(context, this.H) + "->" + d.b.a.d(context, this.J) + " (pos:" + this.O + " Dpos/Dt:" + this.G;
    }

    public void u() {
        CopyOnWriteArrayList<InterfaceC0026c> copyOnWriteArrayList;
        if (!(this.R == null && ((copyOnWriteArrayList = this.f2419b0) == null || copyOnWriteArrayList.isEmpty())) && this.f2420c0 == -1) {
            this.f2420c0 = this.I;
            throw null;
        }
        if (this.R != null) {
            throw null;
        }
        CopyOnWriteArrayList<InterfaceC0026c> copyOnWriteArrayList2 = this.f2419b0;
        if (copyOnWriteArrayList2 != null && !copyOnWriteArrayList2.isEmpty()) {
            throw null;
        }
    }

    public void v(float f2, float f3) {
        if (super.isAttachedToWindow()) {
            setProgress(f2);
            setState(d.MOVING);
            this.G = f3;
        } else {
            if (this.g0 == null) {
                this.g0 = new b();
            }
            b bVar = this.g0;
            bVar.a = f2;
            bVar.f2423b = f3;
        }
    }

    public void w(int i2, int i3) {
        if (super.isAttachedToWindow()) {
            return;
        }
        if (this.g0 == null) {
            this.g0 = new b();
        }
        b bVar = this.g0;
        bVar.f2424c = i2;
        bVar.f2425d = i3;
    }

    public void x(int i2) {
        if (!super.isAttachedToWindow()) {
            if (this.g0 == null) {
                this.g0 = new b();
            }
            this.g0.f2425d = i2;
            return;
        }
        int i3 = this.I;
        if (i3 == i2 || this.H == i2 || this.J == i2) {
            return;
        }
        this.J = i2;
        if (i3 != -1) {
            w(i3, i2);
            this.O = 0.0f;
            return;
        }
        this.Q = 1.0f;
        this.N = 0.0f;
        this.O = 0.0f;
        this.P = getNanoTime();
        this.L = getNanoTime();
        throw null;
    }
}
