Rabbit-R1/android (non root)/java/sources/androidx/constraintlayout/solver/widgets/Barrier.java

148 lines
7 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package androidx.constraintlayout.solver.widgets;
import androidx.constraintlayout.solver.LinearSystem;
import androidx.constraintlayout.solver.SolverVariable;
import androidx.constraintlayout.solver.widgets.ConstraintWidget;
import java.util.HashMap;
/* loaded from: classes.dex */
public class Barrier extends HelperWidget {
public static final int BOTTOM = 3;
public static final int LEFT = 0;
public static final int RIGHT = 1;
public static final int TOP = 2;
private int mBarrierType = 0;
private boolean mAllowsGoneWidget = true;
private int mMargin = 0;
@Override // androidx.constraintlayout.solver.widgets.ConstraintWidget
public boolean allowedInBarrier() {
return true;
}
public boolean allowsGoneWidget() {
return this.mAllowsGoneWidget;
}
public int getBarrierType() {
return this.mBarrierType;
}
public int getMargin() {
return this.mMargin;
}
public void setAllowsGoneWidget(boolean z) {
this.mAllowsGoneWidget = z;
}
public void setBarrierType(int i) {
this.mBarrierType = i;
}
public void setMargin(int i) {
this.mMargin = i;
}
@Override // androidx.constraintlayout.solver.widgets.HelperWidget, androidx.constraintlayout.solver.widgets.ConstraintWidget
public void copy(ConstraintWidget constraintWidget, HashMap<ConstraintWidget, ConstraintWidget> hashMap) {
super.copy(constraintWidget, hashMap);
Barrier barrier = (Barrier) constraintWidget;
this.mBarrierType = barrier.mBarrierType;
this.mAllowsGoneWidget = barrier.mAllowsGoneWidget;
this.mMargin = barrier.mMargin;
}
@Override // androidx.constraintlayout.solver.widgets.ConstraintWidget
public String toString() {
String str = "[Barrier] " + getDebugName() + " {";
for (int i = 0; i < this.mWidgetsCount; i++) {
ConstraintWidget constraintWidget = this.mWidgets[i];
if (i > 0) {
str = str + ", ";
}
str = str + constraintWidget.getDebugName();
}
return str + "}";
}
/* JADX INFO: Access modifiers changed from: protected */
public void markWidgets() {
for (int i = 0; i < this.mWidgetsCount; i++) {
ConstraintWidget constraintWidget = this.mWidgets[i];
int i2 = this.mBarrierType;
if (i2 == 0 || i2 == 1) {
constraintWidget.setInBarrier(0, true);
} else if (i2 == 2 || i2 == 3) {
constraintWidget.setInBarrier(1, true);
}
}
}
@Override // androidx.constraintlayout.solver.widgets.ConstraintWidget
public void addToSolver(LinearSystem linearSystem) {
boolean z;
int i;
int i2;
int i3;
this.mListAnchors[0] = this.mLeft;
this.mListAnchors[2] = this.mTop;
this.mListAnchors[1] = this.mRight;
this.mListAnchors[3] = this.mBottom;
for (int i4 = 0; i4 < this.mListAnchors.length; i4++) {
this.mListAnchors[i4].mSolverVariable = linearSystem.createObjectVariable(this.mListAnchors[i4]);
}
int i5 = this.mBarrierType;
if (i5 < 0 || i5 >= 4) {
return;
}
ConstraintAnchor constraintAnchor = this.mListAnchors[this.mBarrierType];
for (int i6 = 0; i6 < this.mWidgetsCount; i6++) {
ConstraintWidget constraintWidget = this.mWidgets[i6];
if ((this.mAllowsGoneWidget || constraintWidget.allowedInBarrier()) && ((((i2 = this.mBarrierType) == 0 || i2 == 1) && constraintWidget.getHorizontalDimensionBehaviour() == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && constraintWidget.mLeft.mTarget != null && constraintWidget.mRight.mTarget != null) || (((i3 = this.mBarrierType) == 2 || i3 == 3) && constraintWidget.getVerticalDimensionBehaviour() == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && constraintWidget.mTop.mTarget != null && constraintWidget.mBottom.mTarget != null))) {
z = true;
break;
}
}
z = false;
boolean z2 = this.mLeft.hasCenteredDependents() || this.mRight.hasCenteredDependents();
boolean z3 = this.mTop.hasCenteredDependents() || this.mBottom.hasCenteredDependents();
int i7 = !(!z && (((i = this.mBarrierType) == 0 && z2) || ((i == 2 && z3) || ((i == 1 && z2) || (i == 3 && z3))))) ? 4 : 5;
for (int i8 = 0; i8 < this.mWidgetsCount; i8++) {
ConstraintWidget constraintWidget2 = this.mWidgets[i8];
if (this.mAllowsGoneWidget || constraintWidget2.allowedInBarrier()) {
SolverVariable createObjectVariable = linearSystem.createObjectVariable(constraintWidget2.mListAnchors[this.mBarrierType]);
constraintWidget2.mListAnchors[this.mBarrierType].mSolverVariable = createObjectVariable;
int i9 = (constraintWidget2.mListAnchors[this.mBarrierType].mTarget == null || constraintWidget2.mListAnchors[this.mBarrierType].mTarget.mOwner != this) ? 0 : constraintWidget2.mListAnchors[this.mBarrierType].mMargin;
int i10 = this.mBarrierType;
if (i10 == 0 || i10 == 2) {
linearSystem.addLowerBarrier(constraintAnchor.mSolverVariable, createObjectVariable, this.mMargin - i9, z);
} else {
linearSystem.addGreaterBarrier(constraintAnchor.mSolverVariable, createObjectVariable, this.mMargin + i9, z);
}
linearSystem.addEquality(constraintAnchor.mSolverVariable, createObjectVariable, this.mMargin + i9, i7);
}
}
int i11 = this.mBarrierType;
if (i11 == 0) {
linearSystem.addEquality(this.mRight.mSolverVariable, this.mLeft.mSolverVariable, 0, 8);
linearSystem.addEquality(this.mLeft.mSolverVariable, this.mParent.mRight.mSolverVariable, 0, 4);
linearSystem.addEquality(this.mLeft.mSolverVariable, this.mParent.mLeft.mSolverVariable, 0, 0);
return;
}
if (i11 == 1) {
linearSystem.addEquality(this.mLeft.mSolverVariable, this.mRight.mSolverVariable, 0, 8);
linearSystem.addEquality(this.mLeft.mSolverVariable, this.mParent.mLeft.mSolverVariable, 0, 4);
linearSystem.addEquality(this.mLeft.mSolverVariable, this.mParent.mRight.mSolverVariable, 0, 0);
} else if (i11 == 2) {
linearSystem.addEquality(this.mBottom.mSolverVariable, this.mTop.mSolverVariable, 0, 8);
linearSystem.addEquality(this.mTop.mSolverVariable, this.mParent.mBottom.mSolverVariable, 0, 4);
linearSystem.addEquality(this.mTop.mSolverVariable, this.mParent.mTop.mSolverVariable, 0, 0);
} else if (i11 == 3) {
linearSystem.addEquality(this.mTop.mSolverVariable, this.mBottom.mSolverVariable, 0, 8);
linearSystem.addEquality(this.mTop.mSolverVariable, this.mParent.mTop.mSolverVariable, 0, 4);
linearSystem.addEquality(this.mTop.mSolverVariable, this.mParent.mBottom.mSolverVariable, 0, 0);
}
}
}