package androidx.constraintlayout.solver.widgets; import androidx.constraintlayout.solver.LinearSystem; import androidx.constraintlayout.solver.SolverVariable; import androidx.constraintlayout.solver.widgets.ConstraintWidget; import java.util.ArrayList; /* loaded from: classes.dex */ public class Barrier extends Helper { private int m0 = 0; private ArrayList n0 = new ArrayList<>(4); private boolean o0 = true; @Override // androidx.constraintlayout.solver.widgets.ConstraintWidget public void F() { super.F(); this.n0.clear(); } @Override // androidx.constraintlayout.solver.widgets.ConstraintWidget public void G() { ResolutionAnchor d; float f; ResolutionAnchor resolutionAnchor; int i = this.m0; float f2 = Float.MAX_VALUE; if (i != 0) { if (i == 1) { d = this.u.d(); } else if (i == 2) { d = this.t.d(); } else if (i != 3) { return; } else { d = this.v.d(); } f2 = 0.0f; } else { d = this.s.d(); } int size = this.n0.size(); ResolutionAnchor resolutionAnchor2 = null; for (int i2 = 0; i2 < size; i2++) { ResolutionAnchor resolutionAnchor3 = this.n0.get(i2); if (resolutionAnchor3.b != 1) { return; } int i3 = this.m0; if (i3 == 0 || i3 == 2) { f = resolutionAnchor3.g; if (f < f2) { resolutionAnchor = resolutionAnchor3.f; resolutionAnchor2 = resolutionAnchor; f2 = f; } } else { f = resolutionAnchor3.g; if (f > f2) { resolutionAnchor = resolutionAnchor3.f; resolutionAnchor2 = resolutionAnchor; f2 = f; } } } if (LinearSystem.h() != null) { LinearSystem.h().y++; } d.f = resolutionAnchor2; d.g = f2; d.a(); int i4 = this.m0; if (i4 == 0) { this.u.d().a(resolutionAnchor2, f2); return; } if (i4 == 1) { this.s.d().a(resolutionAnchor2, f2); } else if (i4 == 2) { this.v.d().a(resolutionAnchor2, f2); } else { if (i4 != 3) { return; } this.t.d().a(resolutionAnchor2, f2); } } @Override // androidx.constraintlayout.solver.widgets.ConstraintWidget public void a(int i) { ResolutionAnchor d; ConstraintWidget constraintWidget = this.D; if (constraintWidget != null && ((ConstraintWidgetContainer) constraintWidget).t(2)) { int i2 = this.m0; if (i2 == 0) { d = this.s.d(); } else if (i2 == 1) { d = this.u.d(); } else if (i2 == 2) { d = this.t.d(); } else if (i2 != 3) { return; } else { d = this.v.d(); } d.b(5); int i3 = this.m0; if (i3 == 0 || i3 == 1) { this.t.d().a((ResolutionAnchor) null, 0.0f); this.v.d().a((ResolutionAnchor) null, 0.0f); } else { this.s.d().a((ResolutionAnchor) null, 0.0f); this.u.d().a((ResolutionAnchor) null, 0.0f); } this.n0.clear(); for (int i4 = 0; i4 < this.l0; i4++) { ConstraintWidget constraintWidget2 = this.k0[i4]; if (this.o0 || constraintWidget2.a()) { int i5 = this.m0; ResolutionAnchor d2 = i5 != 0 ? i5 != 1 ? i5 != 2 ? i5 != 3 ? null : constraintWidget2.v.d() : constraintWidget2.t.d() : constraintWidget2.u.d() : constraintWidget2.s.d(); if (d2 != null) { this.n0.add(d2); d2.a(d); } } } } } @Override // androidx.constraintlayout.solver.widgets.ConstraintWidget public boolean a() { return true; } public void c(boolean z) { this.o0 = z; } public void t(int i) { this.m0 = i; } @Override // androidx.constraintlayout.solver.widgets.ConstraintWidget public void a(LinearSystem linearSystem) { ConstraintAnchor[] constraintAnchorArr; boolean z; int i; int i2; ConstraintAnchor[] constraintAnchorArr2 = this.A; constraintAnchorArr2[0] = this.s; constraintAnchorArr2[2] = this.t; constraintAnchorArr2[1] = this.u; constraintAnchorArr2[3] = this.v; int i3 = 0; while (true) { constraintAnchorArr = this.A; if (i3 >= constraintAnchorArr.length) { break; } constraintAnchorArr[i3].i = linearSystem.a(constraintAnchorArr[i3]); i3++; } int i4 = this.m0; if (i4 < 0 || i4 >= 4) { return; } ConstraintAnchor constraintAnchor = constraintAnchorArr[i4]; for (int i5 = 0; i5 < this.l0; i5++) { ConstraintWidget constraintWidget = this.k0[i5]; if ((this.o0 || constraintWidget.a()) && ((((i = this.m0) == 0 || i == 1) && constraintWidget.j() == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT) || (((i2 = this.m0) == 2 || i2 == 3) && constraintWidget.q() == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT))) { z = true; break; } } z = false; int i6 = this.m0; if (i6 == 0 || i6 == 1 ? k().j() == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT : k().q() == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT) { z = false; } for (int i7 = 0; i7 < this.l0; i7++) { ConstraintWidget constraintWidget2 = this.k0[i7]; if (this.o0 || constraintWidget2.a()) { SolverVariable a = linearSystem.a(constraintWidget2.A[this.m0]); ConstraintAnchor[] constraintAnchorArr3 = constraintWidget2.A; int i8 = this.m0; constraintAnchorArr3[i8].i = a; if (i8 != 0 && i8 != 2) { linearSystem.a(constraintAnchor.i, a, z); } else { linearSystem.b(constraintAnchor.i, a, z); } } } int i9 = this.m0; if (i9 == 0) { linearSystem.a(this.u.i, this.s.i, 0, 6); if (z) { return; } linearSystem.a(this.s.i, this.D.u.i, 0, 5); return; } if (i9 == 1) { linearSystem.a(this.s.i, this.u.i, 0, 6); if (z) { return; } linearSystem.a(this.s.i, this.D.s.i, 0, 5); return; } if (i9 == 2) { linearSystem.a(this.v.i, this.t.i, 0, 6); if (z) { return; } linearSystem.a(this.t.i, this.D.v.i, 0, 5); return; } if (i9 == 3) { linearSystem.a(this.t.i, this.v.i, 0, 6); if (z) { return; } linearSystem.a(this.t.i, this.D.t.i, 0, 5); } } }