mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-12-01 18:23:27 +01:00
477 lines
16 KiB
Java
477 lines
16 KiB
Java
package androidx.constraintlayout.solver.widgets;
|
|
|
|
import androidx.constraintlayout.solver.Cache;
|
|
import androidx.constraintlayout.solver.SolverVariable;
|
|
import java.util.ArrayList;
|
|
import java.util.HashSet;
|
|
import okio.Buffer$$ExternalSyntheticBUOutline0;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes13.dex */
|
|
public class ConstraintAnchor {
|
|
private static final boolean ALLOW_BINARY = false;
|
|
public static final int AUTO_CONSTRAINT_CREATOR = 2;
|
|
public static final int SCOUT_CREATOR = 1;
|
|
private static final int UNSET_GONE_MARGIN = -1;
|
|
public static final int USER_CREATOR = 0;
|
|
final ConstraintWidget mOwner;
|
|
SolverVariable mSolverVariable;
|
|
ConstraintAnchor mTarget;
|
|
final Type mType;
|
|
private ResolutionAnchor mResolutionAnchor = new ResolutionAnchor(this);
|
|
public int mMargin = 0;
|
|
int mGoneMargin = -1;
|
|
private Strength mStrength = Strength.NONE;
|
|
private ConnectionType mConnectionType = ConnectionType.RELAXED;
|
|
private int mConnectionCreator = 0;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* renamed from: androidx.constraintlayout.solver.widgets.ConstraintAnchor$1, reason: invalid class name */
|
|
public static /* synthetic */ class AnonymousClass1 {
|
|
static final /* synthetic */ int[] $SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type;
|
|
|
|
static {
|
|
int[] iArr = new int[Type.values().length];
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type = iArr;
|
|
try {
|
|
iArr[Type.CENTER.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[Type.LEFT.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
try {
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[Type.RIGHT.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused3) {
|
|
}
|
|
try {
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[Type.TOP.ordinal()] = 4;
|
|
} catch (NoSuchFieldError unused4) {
|
|
}
|
|
try {
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[Type.BOTTOM.ordinal()] = 5;
|
|
} catch (NoSuchFieldError unused5) {
|
|
}
|
|
try {
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[Type.BASELINE.ordinal()] = 6;
|
|
} catch (NoSuchFieldError unused6) {
|
|
}
|
|
try {
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[Type.CENTER_X.ordinal()] = 7;
|
|
} catch (NoSuchFieldError unused7) {
|
|
}
|
|
try {
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[Type.CENTER_Y.ordinal()] = 8;
|
|
} catch (NoSuchFieldError unused8) {
|
|
}
|
|
try {
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[Type.NONE.ordinal()] = 9;
|
|
} catch (NoSuchFieldError unused9) {
|
|
}
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum ConnectionType {
|
|
RELAXED,
|
|
STRICT
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum Strength {
|
|
NONE,
|
|
STRONG,
|
|
WEAK
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum Type {
|
|
NONE,
|
|
LEFT,
|
|
TOP,
|
|
RIGHT,
|
|
BOTTOM,
|
|
BASELINE,
|
|
CENTER,
|
|
CENTER_X,
|
|
CENTER_Y
|
|
}
|
|
|
|
public ConstraintAnchor(ConstraintWidget constraintWidget, Type type) {
|
|
this.mOwner = constraintWidget;
|
|
this.mType = type;
|
|
}
|
|
|
|
private boolean isConnectionToMe(ConstraintWidget constraintWidget, HashSet<ConstraintWidget> hashSet) {
|
|
if (hashSet.contains(constraintWidget)) {
|
|
return false;
|
|
}
|
|
hashSet.add(constraintWidget);
|
|
if (constraintWidget == getOwner()) {
|
|
return true;
|
|
}
|
|
ArrayList<ConstraintAnchor> anchors = constraintWidget.getAnchors();
|
|
int size = anchors.size();
|
|
for (int i = 0; i < size; i++) {
|
|
ConstraintAnchor constraintAnchor = anchors.get(i);
|
|
if (constraintAnchor.isSimilarDimensionConnection(this) && constraintAnchor.isConnected() && isConnectionToMe(constraintAnchor.getTarget().getOwner(), hashSet)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public boolean connect(ConstraintAnchor constraintAnchor, int i, int i2, Strength strength, int i3, boolean z) {
|
|
if (constraintAnchor == null) {
|
|
this.mTarget = null;
|
|
this.mMargin = 0;
|
|
this.mGoneMargin = -1;
|
|
this.mStrength = Strength.NONE;
|
|
this.mConnectionCreator = 2;
|
|
return true;
|
|
}
|
|
if (!z && !isValidConnection(constraintAnchor)) {
|
|
return false;
|
|
}
|
|
this.mTarget = constraintAnchor;
|
|
if (i > 0) {
|
|
this.mMargin = i;
|
|
} else {
|
|
this.mMargin = 0;
|
|
}
|
|
this.mGoneMargin = i2;
|
|
this.mStrength = strength;
|
|
this.mConnectionCreator = i3;
|
|
return true;
|
|
}
|
|
|
|
public int getConnectionCreator() {
|
|
return this.mConnectionCreator;
|
|
}
|
|
|
|
public ConnectionType getConnectionType() {
|
|
return this.mConnectionType;
|
|
}
|
|
|
|
public int getMargin() {
|
|
ConstraintAnchor constraintAnchor;
|
|
if (this.mOwner.getVisibility() == 8) {
|
|
return 0;
|
|
}
|
|
return (this.mGoneMargin <= -1 || (constraintAnchor = this.mTarget) == null || constraintAnchor.mOwner.getVisibility() != 8) ? this.mMargin : this.mGoneMargin;
|
|
}
|
|
|
|
public final ConstraintAnchor getOpposite() {
|
|
switch (AnonymousClass1.$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[this.mType.ordinal()]) {
|
|
case 1:
|
|
case 6:
|
|
case 7:
|
|
case 8:
|
|
case 9:
|
|
return null;
|
|
case 2:
|
|
return this.mOwner.mRight;
|
|
case 3:
|
|
return this.mOwner.mLeft;
|
|
case 4:
|
|
return this.mOwner.mBottom;
|
|
case 5:
|
|
return this.mOwner.mTop;
|
|
default:
|
|
Buffer$$ExternalSyntheticBUOutline0.m((Object) this.mType.name());
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public ConstraintWidget getOwner() {
|
|
return this.mOwner;
|
|
}
|
|
|
|
public int getPriorityLevel() {
|
|
switch (AnonymousClass1.$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[this.mType.ordinal()]) {
|
|
case 1:
|
|
case 2:
|
|
case 3:
|
|
case 4:
|
|
case 5:
|
|
break;
|
|
case 6:
|
|
break;
|
|
case 7:
|
|
case 8:
|
|
case 9:
|
|
break;
|
|
default:
|
|
Buffer$$ExternalSyntheticBUOutline0.m((Object) this.mType.name());
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public ResolutionAnchor getResolutionNode() {
|
|
return this.mResolutionAnchor;
|
|
}
|
|
|
|
public int getSnapPriorityLevel() {
|
|
switch (AnonymousClass1.$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[this.mType.ordinal()]) {
|
|
case 1:
|
|
break;
|
|
case 2:
|
|
case 3:
|
|
break;
|
|
case 4:
|
|
case 5:
|
|
break;
|
|
case 6:
|
|
break;
|
|
case 7:
|
|
break;
|
|
case 8:
|
|
break;
|
|
case 9:
|
|
break;
|
|
default:
|
|
Buffer$$ExternalSyntheticBUOutline0.m((Object) this.mType.name());
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public SolverVariable getSolverVariable() {
|
|
return this.mSolverVariable;
|
|
}
|
|
|
|
public Strength getStrength() {
|
|
return this.mStrength;
|
|
}
|
|
|
|
public ConstraintAnchor getTarget() {
|
|
return this.mTarget;
|
|
}
|
|
|
|
public Type getType() {
|
|
return this.mType;
|
|
}
|
|
|
|
public boolean isConnected() {
|
|
return this.mTarget != null;
|
|
}
|
|
|
|
public boolean isConnectionAllowed(ConstraintWidget constraintWidget) {
|
|
if (isConnectionToMe(constraintWidget, new HashSet<>())) {
|
|
return false;
|
|
}
|
|
ConstraintWidget parent = getOwner().getParent();
|
|
return parent == constraintWidget || constraintWidget.getParent() == parent;
|
|
}
|
|
|
|
public boolean isSideAnchor() {
|
|
switch (AnonymousClass1.$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[this.mType.ordinal()]) {
|
|
case 1:
|
|
case 6:
|
|
case 7:
|
|
case 8:
|
|
case 9:
|
|
return false;
|
|
case 2:
|
|
case 3:
|
|
case 4:
|
|
case 5:
|
|
return true;
|
|
default:
|
|
Buffer$$ExternalSyntheticBUOutline0.m((Object) this.mType.name());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public boolean isSimilarDimensionConnection(ConstraintAnchor constraintAnchor) {
|
|
Type type = constraintAnchor.getType();
|
|
Type type2 = this.mType;
|
|
if (type == type2) {
|
|
return true;
|
|
}
|
|
switch (AnonymousClass1.$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[type2.ordinal()]) {
|
|
case 1:
|
|
return type != Type.BASELINE;
|
|
case 2:
|
|
case 3:
|
|
case 7:
|
|
return type == Type.LEFT || type == Type.RIGHT || type == Type.CENTER_X;
|
|
case 4:
|
|
case 5:
|
|
case 6:
|
|
case 8:
|
|
return type == Type.TOP || type == Type.BOTTOM || type == Type.CENTER_Y || type == Type.BASELINE;
|
|
case 9:
|
|
return false;
|
|
default:
|
|
Buffer$$ExternalSyntheticBUOutline0.m((Object) this.mType.name());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public boolean isSnapCompatibleWith(ConstraintAnchor constraintAnchor) {
|
|
Type type = this.mType;
|
|
if (type == Type.CENTER) {
|
|
return false;
|
|
}
|
|
if (type == constraintAnchor.getType()) {
|
|
return true;
|
|
}
|
|
int[] iArr = AnonymousClass1.$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type;
|
|
switch (iArr[this.mType.ordinal()]) {
|
|
case 1:
|
|
case 6:
|
|
case 9:
|
|
return false;
|
|
case 2:
|
|
int i = iArr[constraintAnchor.getType().ordinal()];
|
|
return i == 3 || i == 7;
|
|
case 3:
|
|
int i2 = iArr[constraintAnchor.getType().ordinal()];
|
|
return i2 == 2 || i2 == 7;
|
|
case 4:
|
|
int i3 = iArr[constraintAnchor.getType().ordinal()];
|
|
return i3 == 5 || i3 == 8;
|
|
case 5:
|
|
int i4 = iArr[constraintAnchor.getType().ordinal()];
|
|
return i4 == 4 || i4 == 8;
|
|
case 7:
|
|
int i5 = iArr[constraintAnchor.getType().ordinal()];
|
|
return i5 == 2 || i5 == 3;
|
|
case 8:
|
|
int i6 = iArr[constraintAnchor.getType().ordinal()];
|
|
return i6 == 4 || i6 == 5;
|
|
default:
|
|
Buffer$$ExternalSyntheticBUOutline0.m((Object) this.mType.name());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public boolean isValidConnection(ConstraintAnchor constraintAnchor) {
|
|
if (constraintAnchor == null) {
|
|
return false;
|
|
}
|
|
Type type = constraintAnchor.getType();
|
|
Type type2 = this.mType;
|
|
if (type == type2) {
|
|
return type2 != Type.BASELINE || (constraintAnchor.getOwner().hasBaseline() && getOwner().hasBaseline());
|
|
}
|
|
switch (AnonymousClass1.$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[type2.ordinal()]) {
|
|
case 1:
|
|
if (type == Type.BASELINE || type == Type.CENTER_X || type == Type.CENTER_Y) {
|
|
}
|
|
break;
|
|
case 2:
|
|
case 3:
|
|
boolean z = type == Type.LEFT || type == Type.RIGHT;
|
|
if (constraintAnchor.getOwner() instanceof Guideline) {
|
|
if (z || type == Type.CENTER_X) {
|
|
}
|
|
}
|
|
break;
|
|
case 4:
|
|
case 5:
|
|
boolean z2 = type == Type.TOP || type == Type.BOTTOM;
|
|
if (constraintAnchor.getOwner() instanceof Guideline) {
|
|
if (z2 || type == Type.CENTER_Y) {
|
|
}
|
|
}
|
|
break;
|
|
case 6:
|
|
case 7:
|
|
case 8:
|
|
case 9:
|
|
break;
|
|
default:
|
|
Buffer$$ExternalSyntheticBUOutline0.m((Object) this.mType.name());
|
|
break;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public boolean isVerticalAnchor() {
|
|
switch (AnonymousClass1.$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[this.mType.ordinal()]) {
|
|
case 1:
|
|
case 2:
|
|
case 3:
|
|
case 7:
|
|
return false;
|
|
case 4:
|
|
case 5:
|
|
case 6:
|
|
case 8:
|
|
case 9:
|
|
return true;
|
|
default:
|
|
Buffer$$ExternalSyntheticBUOutline0.m((Object) this.mType.name());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public void reset() {
|
|
this.mTarget = null;
|
|
this.mMargin = 0;
|
|
this.mGoneMargin = -1;
|
|
this.mStrength = Strength.STRONG;
|
|
this.mConnectionCreator = 0;
|
|
this.mConnectionType = ConnectionType.RELAXED;
|
|
this.mResolutionAnchor.reset();
|
|
}
|
|
|
|
public void resetSolverVariable(Cache cache) {
|
|
SolverVariable solverVariable = this.mSolverVariable;
|
|
if (solverVariable == null) {
|
|
this.mSolverVariable = new SolverVariable(SolverVariable.Type.UNRESTRICTED, (String) null);
|
|
} else {
|
|
solverVariable.reset();
|
|
}
|
|
}
|
|
|
|
public void setConnectionCreator(int i) {
|
|
this.mConnectionCreator = i;
|
|
}
|
|
|
|
public void setConnectionType(ConnectionType connectionType) {
|
|
this.mConnectionType = connectionType;
|
|
}
|
|
|
|
public void setGoneMargin(int i) {
|
|
if (isConnected()) {
|
|
this.mGoneMargin = i;
|
|
}
|
|
}
|
|
|
|
public void setMargin(int i) {
|
|
if (isConnected()) {
|
|
this.mMargin = i;
|
|
}
|
|
}
|
|
|
|
public void setStrength(Strength strength) {
|
|
if (isConnected()) {
|
|
this.mStrength = strength;
|
|
}
|
|
}
|
|
|
|
public String toString() {
|
|
return this.mOwner.getDebugName() + ":" + this.mType.toString();
|
|
}
|
|
|
|
public boolean isConnectionAllowed(ConstraintWidget constraintWidget, ConstraintAnchor constraintAnchor) {
|
|
return isConnectionAllowed(constraintWidget);
|
|
}
|
|
|
|
public boolean connect(ConstraintAnchor constraintAnchor, int i, Strength strength, int i2) {
|
|
return connect(constraintAnchor, i, -1, strength, i2, false);
|
|
}
|
|
|
|
public boolean connect(ConstraintAnchor constraintAnchor, int i, int i2) {
|
|
return connect(constraintAnchor, i, -1, Strength.STRONG, i2, false);
|
|
}
|
|
|
|
public boolean connect(ConstraintAnchor constraintAnchor, int i) {
|
|
return connect(constraintAnchor, i, -1, Strength.STRONG, 0, false);
|
|
}
|
|
}
|