2021-07-24 02:37:17 +00:00
|
|
|
package androidx.constraintlayout.solver.widgets;
|
|
|
|
|
|
|
|
import androidx.constraintlayout.solver.LinearSystem;
|
|
|
|
import androidx.constraintlayout.solver.SolverVariable;
|
|
|
|
import androidx.constraintlayout.solver.widgets.ConstraintAnchor;
|
|
|
|
import androidx.constraintlayout.solver.widgets.ConstraintWidget;
|
|
|
|
import java.util.HashMap;
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public class Guideline extends ConstraintWidget {
|
|
|
|
public static final int HORIZONTAL = 0;
|
|
|
|
public static final int RELATIVE_BEGIN = 1;
|
|
|
|
public static final int RELATIVE_END = 2;
|
|
|
|
public static final int RELATIVE_PERCENT = 0;
|
|
|
|
public static final int RELATIVE_UNKNWON = -1;
|
|
|
|
public static final int VERTICAL = 1;
|
2022-03-07 09:34:54 +00:00
|
|
|
private boolean resolved;
|
|
|
|
public float mRelativePercent = -1.0f;
|
2021-07-24 02:37:17 +00:00
|
|
|
public int mRelativeBegin = -1;
|
|
|
|
public int mRelativeEnd = -1;
|
2022-03-07 09:34:54 +00:00
|
|
|
private ConstraintAnchor mAnchor = this.mTop;
|
|
|
|
private int mOrientation = 0;
|
|
|
|
private int mMinimumPosition = 0;
|
2021-07-24 02:37:17 +00:00
|
|
|
|
|
|
|
/* renamed from: androidx.constraintlayout.solver.widgets.Guideline$1 reason: invalid class name */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public static /* synthetic */ class AnonymousClass1 {
|
|
|
|
public static final /* synthetic */ int[] $SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type;
|
|
|
|
|
|
|
|
static {
|
|
|
|
ConstraintAnchor.Type.values();
|
|
|
|
int[] iArr = new int[9];
|
|
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type = iArr;
|
|
|
|
try {
|
|
|
|
iArr[ConstraintAnchor.Type.LEFT.ordinal()] = 1;
|
|
|
|
} catch (NoSuchFieldError unused) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[ConstraintAnchor.Type.RIGHT.ordinal()] = 2;
|
|
|
|
} catch (NoSuchFieldError unused2) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[ConstraintAnchor.Type.TOP.ordinal()] = 3;
|
|
|
|
} catch (NoSuchFieldError unused3) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[ConstraintAnchor.Type.BOTTOM.ordinal()] = 4;
|
|
|
|
} catch (NoSuchFieldError unused4) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[ConstraintAnchor.Type.BASELINE.ordinal()] = 5;
|
|
|
|
} catch (NoSuchFieldError unused5) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[ConstraintAnchor.Type.CENTER.ordinal()] = 6;
|
|
|
|
} catch (NoSuchFieldError unused6) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[ConstraintAnchor.Type.CENTER_X.ordinal()] = 7;
|
|
|
|
} catch (NoSuchFieldError unused7) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[ConstraintAnchor.Type.CENTER_Y.ordinal()] = 8;
|
|
|
|
} catch (NoSuchFieldError unused8) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[ConstraintAnchor.Type.NONE.ordinal()] = 9;
|
|
|
|
} catch (NoSuchFieldError unused9) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public Guideline() {
|
|
|
|
this.mAnchors.clear();
|
|
|
|
this.mAnchors.add(this.mAnchor);
|
|
|
|
int length = this.mListAnchors.length;
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
|
this.mListAnchors[i] = this.mAnchor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.solver.widgets.ConstraintWidget
|
|
|
|
public void addToSolver(LinearSystem linearSystem, boolean z2) {
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer = (ConstraintWidgetContainer) getParent();
|
|
|
|
if (constraintWidgetContainer != null) {
|
|
|
|
ConstraintAnchor anchor = constraintWidgetContainer.getAnchor(ConstraintAnchor.Type.LEFT);
|
|
|
|
ConstraintAnchor anchor2 = constraintWidgetContainer.getAnchor(ConstraintAnchor.Type.RIGHT);
|
|
|
|
ConstraintWidget constraintWidget = this.mParent;
|
|
|
|
boolean z3 = true;
|
2022-03-07 09:34:54 +00:00
|
|
|
z3 = constraintWidget != null && constraintWidget.mListDimensionBehaviors[0] == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
2021-07-24 02:37:17 +00:00
|
|
|
if (this.mOrientation == 0) {
|
|
|
|
anchor = constraintWidgetContainer.getAnchor(ConstraintAnchor.Type.TOP);
|
|
|
|
anchor2 = constraintWidgetContainer.getAnchor(ConstraintAnchor.Type.BOTTOM);
|
|
|
|
ConstraintWidget constraintWidget2 = this.mParent;
|
|
|
|
if (constraintWidget2 == null || constraintWidget2.mListDimensionBehaviors[1] != ConstraintWidget.DimensionBehaviour.WRAP_CONTENT) {
|
|
|
|
z3 = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (this.resolved && this.mAnchor.hasFinalValue()) {
|
|
|
|
SolverVariable createObjectVariable = linearSystem.createObjectVariable(this.mAnchor);
|
|
|
|
linearSystem.addEquality(createObjectVariable, this.mAnchor.getFinalValue());
|
|
|
|
if (this.mRelativeBegin != -1) {
|
2022-03-07 09:34:54 +00:00
|
|
|
if (z3) {
|
2021-07-24 02:37:17 +00:00
|
|
|
linearSystem.addGreaterThan(linearSystem.createObjectVariable(anchor2), createObjectVariable, 0, 5);
|
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
} else if (this.mRelativeEnd != -1 && z3) {
|
2021-07-24 02:37:17 +00:00
|
|
|
SolverVariable createObjectVariable2 = linearSystem.createObjectVariable(anchor2);
|
|
|
|
linearSystem.addGreaterThan(createObjectVariable, linearSystem.createObjectVariable(anchor), 0, 5);
|
|
|
|
linearSystem.addGreaterThan(createObjectVariable2, createObjectVariable, 0, 5);
|
|
|
|
}
|
|
|
|
this.resolved = false;
|
|
|
|
} else if (this.mRelativeBegin != -1) {
|
|
|
|
SolverVariable createObjectVariable3 = linearSystem.createObjectVariable(this.mAnchor);
|
|
|
|
linearSystem.addEquality(createObjectVariable3, linearSystem.createObjectVariable(anchor), this.mRelativeBegin, 8);
|
2022-03-07 09:34:54 +00:00
|
|
|
if (z3) {
|
2021-07-24 02:37:17 +00:00
|
|
|
linearSystem.addGreaterThan(linearSystem.createObjectVariable(anchor2), createObjectVariable3, 0, 5);
|
|
|
|
}
|
|
|
|
} else if (this.mRelativeEnd != -1) {
|
|
|
|
SolverVariable createObjectVariable4 = linearSystem.createObjectVariable(this.mAnchor);
|
|
|
|
SolverVariable createObjectVariable5 = linearSystem.createObjectVariable(anchor2);
|
|
|
|
linearSystem.addEquality(createObjectVariable4, createObjectVariable5, -this.mRelativeEnd, 8);
|
2022-03-07 09:34:54 +00:00
|
|
|
if (z3) {
|
2021-07-24 02:37:17 +00:00
|
|
|
linearSystem.addGreaterThan(createObjectVariable4, linearSystem.createObjectVariable(anchor), 0, 5);
|
|
|
|
linearSystem.addGreaterThan(createObjectVariable5, createObjectVariable4, 0, 5);
|
|
|
|
}
|
|
|
|
} else if (this.mRelativePercent != -1.0f) {
|
|
|
|
linearSystem.addConstraint(LinearSystem.createRowDimensionPercent(linearSystem, linearSystem.createObjectVariable(this.mAnchor), linearSystem.createObjectVariable(anchor2), this.mRelativePercent));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.solver.widgets.ConstraintWidget
|
|
|
|
public boolean allowedInBarrier() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.solver.widgets.ConstraintWidget
|
|
|
|
public void copy(ConstraintWidget constraintWidget, HashMap<ConstraintWidget, ConstraintWidget> hashMap) {
|
|
|
|
super.copy(constraintWidget, hashMap);
|
|
|
|
Guideline guideline = (Guideline) constraintWidget;
|
|
|
|
this.mRelativePercent = guideline.mRelativePercent;
|
|
|
|
this.mRelativeBegin = guideline.mRelativeBegin;
|
|
|
|
this.mRelativeEnd = guideline.mRelativeEnd;
|
|
|
|
setOrientation(guideline.mOrientation);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void cyclePosition() {
|
|
|
|
if (this.mRelativeBegin != -1) {
|
|
|
|
inferRelativePercentPosition();
|
|
|
|
} else if (this.mRelativePercent != -1.0f) {
|
|
|
|
inferRelativeEndPosition();
|
|
|
|
} else if (this.mRelativeEnd != -1) {
|
|
|
|
inferRelativeBeginPosition();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public ConstraintAnchor getAnchor() {
|
|
|
|
return this.mAnchor;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.solver.widgets.ConstraintWidget
|
|
|
|
public ConstraintAnchor getAnchor(ConstraintAnchor.Type type) {
|
|
|
|
switch (type.ordinal()) {
|
|
|
|
case 0:
|
|
|
|
case 5:
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
case 8:
|
|
|
|
return null;
|
|
|
|
case 1:
|
|
|
|
case 3:
|
|
|
|
if (this.mOrientation == 1) {
|
|
|
|
return this.mAnchor;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 4:
|
|
|
|
if (this.mOrientation == 0) {
|
|
|
|
return this.mAnchor;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
throw new AssertionError(type.name());
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getOrientation() {
|
|
|
|
return this.mOrientation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getRelativeBegin() {
|
|
|
|
return this.mRelativeBegin;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getRelativeBehaviour() {
|
|
|
|
if (this.mRelativePercent != -1.0f) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (this.mRelativeBegin != -1) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return this.mRelativeEnd != -1 ? 2 : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getRelativeEnd() {
|
|
|
|
return this.mRelativeEnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getRelativePercent() {
|
|
|
|
return this.mRelativePercent;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.solver.widgets.ConstraintWidget
|
|
|
|
public String getType() {
|
|
|
|
return "Guideline";
|
|
|
|
}
|
|
|
|
|
|
|
|
public void inferRelativeBeginPosition() {
|
|
|
|
int x2 = getX();
|
|
|
|
if (this.mOrientation == 0) {
|
|
|
|
x2 = getY();
|
|
|
|
}
|
|
|
|
setGuideBegin(x2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void inferRelativeEndPosition() {
|
|
|
|
int width = getParent().getWidth() - getX();
|
|
|
|
if (this.mOrientation == 0) {
|
|
|
|
width = getParent().getHeight() - getY();
|
|
|
|
}
|
|
|
|
setGuideEnd(width);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void inferRelativePercentPosition() {
|
2022-03-07 09:34:54 +00:00
|
|
|
float x2 = getX() / getParent().getWidth();
|
2021-07-24 02:37:17 +00:00
|
|
|
if (this.mOrientation == 0) {
|
2022-03-07 09:34:54 +00:00
|
|
|
x2 = getY() / getParent().getHeight();
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
setGuidePercent(x2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isPercent() {
|
|
|
|
return this.mRelativePercent != -1.0f && this.mRelativeBegin == -1 && this.mRelativeEnd == -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.solver.widgets.ConstraintWidget
|
|
|
|
public boolean isResolvedHorizontally() {
|
|
|
|
return this.resolved;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.solver.widgets.ConstraintWidget
|
|
|
|
public boolean isResolvedVertically() {
|
|
|
|
return this.resolved;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFinalValue(int i) {
|
|
|
|
this.mAnchor.setFinalValue(i);
|
|
|
|
this.resolved = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setGuideBegin(int i) {
|
|
|
|
if (i > -1) {
|
|
|
|
this.mRelativePercent = -1.0f;
|
|
|
|
this.mRelativeBegin = i;
|
|
|
|
this.mRelativeEnd = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setGuideEnd(int i) {
|
|
|
|
if (i > -1) {
|
|
|
|
this.mRelativePercent = -1.0f;
|
|
|
|
this.mRelativeBegin = -1;
|
|
|
|
this.mRelativeEnd = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setGuidePercent(float f) {
|
|
|
|
if (f > -1.0f) {
|
|
|
|
this.mRelativePercent = f;
|
|
|
|
this.mRelativeBegin = -1;
|
|
|
|
this.mRelativeEnd = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setGuidePercent(int i) {
|
2022-03-07 09:34:54 +00:00
|
|
|
setGuidePercent(i / 100.0f);
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setMinimumPosition(int i) {
|
|
|
|
this.mMinimumPosition = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOrientation(int i) {
|
|
|
|
if (this.mOrientation != i) {
|
|
|
|
this.mOrientation = i;
|
|
|
|
this.mAnchors.clear();
|
|
|
|
if (this.mOrientation == 1) {
|
|
|
|
this.mAnchor = this.mLeft;
|
|
|
|
} else {
|
|
|
|
this.mAnchor = this.mTop;
|
|
|
|
}
|
|
|
|
this.mAnchors.add(this.mAnchor);
|
|
|
|
int length = this.mListAnchors.length;
|
|
|
|
for (int i2 = 0; i2 < length; i2++) {
|
|
|
|
this.mListAnchors[i2] = this.mAnchor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.constraintlayout.solver.widgets.ConstraintWidget
|
|
|
|
public void updateFromSolver(LinearSystem linearSystem, boolean z2) {
|
|
|
|
if (getParent() != null) {
|
|
|
|
int objectVariableValue = linearSystem.getObjectVariableValue(this.mAnchor);
|
|
|
|
if (this.mOrientation == 1) {
|
|
|
|
setX(objectVariableValue);
|
|
|
|
setY(0);
|
|
|
|
setHeight(getParent().getHeight());
|
|
|
|
setWidth(0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
setX(0);
|
|
|
|
setY(objectVariableValue);
|
|
|
|
setWidth(getParent().getWidth());
|
|
|
|
setHeight(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|