discord-jadx/app/src/main/java/androidx/constraintlayout/solver/state/ConstraintReference.java

749 lines
27 KiB
Java

package androidx.constraintlayout.solver.state;
import androidx.constraintlayout.solver.state.State;
import androidx.constraintlayout.solver.widgets.ConstraintAnchor;
import androidx.constraintlayout.solver.widgets.ConstraintWidget;
import c.d.b.a.a;
import java.util.ArrayList;
public class ConstraintReference implements Reference {
private Object key;
public Object mBaselineToBaseline = null;
public Object mBottomToBottom = null;
public Object mBottomToTop = null;
private ConstraintWidget mConstraintWidget;
public Object mEndToEnd = null;
public Object mEndToStart = null;
public float mHorizontalBias = 0.5f;
public int mHorizontalChainStyle = 0;
public Dimension mHorizontalDimension;
public State.Constraint mLast = null;
public Object mLeftToLeft = null;
public Object mLeftToRight = null;
public int mMarginBottom = 0;
public int mMarginBottomGone = 0;
public int mMarginEnd = 0;
public int mMarginEndGone = 0;
public int mMarginLeft = 0;
public int mMarginLeftGone = 0;
public int mMarginRight = 0;
public int mMarginRightGone = 0;
public int mMarginStart = 0;
public int mMarginStartGone = 0;
public int mMarginTop = 0;
public int mMarginTopGone = 0;
public Object mRightToLeft = null;
public Object mRightToRight = null;
public Object mStartToEnd = null;
public Object mStartToStart = null;
public final State mState;
public Object mTopToBottom = null;
public Object mTopToTop = null;
public float mVerticalBias = 0.5f;
public int mVerticalChainStyle = 0;
public Dimension mVerticalDimension;
private Object mView;
/* renamed from: androidx.constraintlayout.solver.state.ConstraintReference$1 reason: invalid class name */
public static /* synthetic */ class AnonymousClass1 {
public static final /* synthetic */ int[] $SwitchMap$androidx$constraintlayout$solver$state$State$Constraint;
static {
State.Constraint.values();
int[] iArr = new int[15];
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint = iArr;
try {
iArr[State.Constraint.LEFT_TO_LEFT.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[State.Constraint.LEFT_TO_RIGHT.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[State.Constraint.RIGHT_TO_LEFT.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[State.Constraint.RIGHT_TO_RIGHT.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[State.Constraint.START_TO_START.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[State.Constraint.START_TO_END.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[State.Constraint.END_TO_START.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
try {
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[State.Constraint.END_TO_END.ordinal()] = 8;
} catch (NoSuchFieldError unused8) {
}
try {
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[State.Constraint.TOP_TO_TOP.ordinal()] = 9;
} catch (NoSuchFieldError unused9) {
}
try {
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[State.Constraint.TOP_TO_BOTTOM.ordinal()] = 10;
} catch (NoSuchFieldError unused10) {
}
try {
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[State.Constraint.BOTTOM_TO_TOP.ordinal()] = 11;
} catch (NoSuchFieldError unused11) {
}
try {
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[State.Constraint.BOTTOM_TO_BOTTOM.ordinal()] = 12;
} catch (NoSuchFieldError unused12) {
}
try {
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[State.Constraint.BASELINE_TO_BASELINE.ordinal()] = 13;
} catch (NoSuchFieldError unused13) {
}
try {
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[State.Constraint.CENTER_HORIZONTALLY.ordinal()] = 14;
} catch (NoSuchFieldError unused14) {
}
try {
$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[State.Constraint.CENTER_VERTICALLY.ordinal()] = 15;
} catch (NoSuchFieldError unused15) {
}
}
}
public interface ConstraintReferenceFactory {
ConstraintReference create(State state);
}
public class IncorrectConstraintException extends Exception {
private final ArrayList<String> mErrors;
public IncorrectConstraintException(ArrayList<String> arrayList) {
this.mErrors = arrayList;
}
public ArrayList<String> getErrors() {
return this.mErrors;
}
@Override // java.lang.Throwable, java.lang.Object
public String toString() {
StringBuilder L = a.L("IncorrectConstraintException: ");
L.append(this.mErrors.toString());
return L.toString();
}
}
public ConstraintReference(State state) {
Object obj = Dimension.WRAP_DIMENSION;
this.mHorizontalDimension = Dimension.Fixed(obj);
this.mVerticalDimension = Dimension.Fixed(obj);
this.mState = state;
}
private void applyConnection(ConstraintWidget constraintWidget, Object obj, State.Constraint constraint) {
ConstraintWidget target = getTarget(obj);
if (target != null) {
int i = AnonymousClass1.$SwitchMap$androidx$constraintlayout$solver$state$State$Constraint[constraint.ordinal()];
switch (constraint.ordinal()) {
case 0:
ConstraintAnchor.Type type = ConstraintAnchor.Type.LEFT;
constraintWidget.getAnchor(type).connect(target.getAnchor(type), this.mMarginLeft, this.mMarginLeftGone, false);
return;
case 1:
constraintWidget.getAnchor(ConstraintAnchor.Type.LEFT).connect(target.getAnchor(ConstraintAnchor.Type.RIGHT), this.mMarginLeft, this.mMarginLeftGone, false);
return;
case 2:
constraintWidget.getAnchor(ConstraintAnchor.Type.RIGHT).connect(target.getAnchor(ConstraintAnchor.Type.LEFT), this.mMarginRight, this.mMarginRightGone, false);
return;
case 3:
ConstraintAnchor.Type type2 = ConstraintAnchor.Type.RIGHT;
constraintWidget.getAnchor(type2).connect(target.getAnchor(type2), this.mMarginRight, this.mMarginRightGone, false);
return;
case 4:
ConstraintAnchor.Type type3 = ConstraintAnchor.Type.LEFT;
constraintWidget.getAnchor(type3).connect(target.getAnchor(type3), this.mMarginStart, this.mMarginStartGone, false);
return;
case 5:
constraintWidget.getAnchor(ConstraintAnchor.Type.LEFT).connect(target.getAnchor(ConstraintAnchor.Type.RIGHT), this.mMarginStart, this.mMarginStartGone, false);
return;
case 6:
constraintWidget.getAnchor(ConstraintAnchor.Type.RIGHT).connect(target.getAnchor(ConstraintAnchor.Type.LEFT), this.mMarginEnd, this.mMarginEndGone, false);
return;
case 7:
ConstraintAnchor.Type type4 = ConstraintAnchor.Type.RIGHT;
constraintWidget.getAnchor(type4).connect(target.getAnchor(type4), this.mMarginEnd, this.mMarginEndGone, false);
return;
case 8:
ConstraintAnchor.Type type5 = ConstraintAnchor.Type.TOP;
constraintWidget.getAnchor(type5).connect(target.getAnchor(type5), this.mMarginTop, this.mMarginTopGone, false);
return;
case 9:
constraintWidget.getAnchor(ConstraintAnchor.Type.TOP).connect(target.getAnchor(ConstraintAnchor.Type.BOTTOM), this.mMarginTop, this.mMarginTopGone, false);
return;
case 10:
constraintWidget.getAnchor(ConstraintAnchor.Type.BOTTOM).connect(target.getAnchor(ConstraintAnchor.Type.TOP), this.mMarginBottom, this.mMarginBottomGone, false);
return;
case 11:
ConstraintAnchor.Type type6 = ConstraintAnchor.Type.BOTTOM;
constraintWidget.getAnchor(type6).connect(target.getAnchor(type6), this.mMarginBottom, this.mMarginBottomGone, false);
return;
case 12:
ConstraintAnchor.Type type7 = ConstraintAnchor.Type.BASELINE;
constraintWidget.immediateConnect(type7, target, type7, 0, 0);
return;
default:
return;
}
}
}
private void dereference() {
this.mLeftToLeft = get(this.mLeftToLeft);
this.mLeftToRight = get(this.mLeftToRight);
this.mRightToLeft = get(this.mRightToLeft);
this.mRightToRight = get(this.mRightToRight);
this.mStartToStart = get(this.mStartToStart);
this.mStartToEnd = get(this.mStartToEnd);
this.mEndToStart = get(this.mEndToStart);
this.mEndToEnd = get(this.mEndToEnd);
this.mTopToTop = get(this.mTopToTop);
this.mTopToBottom = get(this.mTopToBottom);
this.mBottomToTop = get(this.mBottomToTop);
this.mBottomToBottom = get(this.mBottomToBottom);
this.mBaselineToBaseline = get(this.mBaselineToBaseline);
}
private Object get(Object obj) {
if (obj == null) {
return null;
}
return !(obj instanceof ConstraintReference) ? this.mState.reference(obj) : obj;
}
private ConstraintWidget getTarget(Object obj) {
if (obj instanceof Reference) {
return ((Reference) obj).getConstraintWidget();
}
return null;
}
@Override // androidx.constraintlayout.solver.state.Reference
public void apply() {
ConstraintWidget constraintWidget = this.mConstraintWidget;
if (constraintWidget != null) {
this.mHorizontalDimension.apply(this.mState, constraintWidget, 0);
this.mVerticalDimension.apply(this.mState, this.mConstraintWidget, 1);
dereference();
applyConnection(this.mConstraintWidget, this.mLeftToLeft, State.Constraint.LEFT_TO_LEFT);
applyConnection(this.mConstraintWidget, this.mLeftToRight, State.Constraint.LEFT_TO_RIGHT);
applyConnection(this.mConstraintWidget, this.mRightToLeft, State.Constraint.RIGHT_TO_LEFT);
applyConnection(this.mConstraintWidget, this.mRightToRight, State.Constraint.RIGHT_TO_RIGHT);
applyConnection(this.mConstraintWidget, this.mStartToStart, State.Constraint.START_TO_START);
applyConnection(this.mConstraintWidget, this.mStartToEnd, State.Constraint.START_TO_END);
applyConnection(this.mConstraintWidget, this.mEndToStart, State.Constraint.END_TO_START);
applyConnection(this.mConstraintWidget, this.mEndToEnd, State.Constraint.END_TO_END);
applyConnection(this.mConstraintWidget, this.mTopToTop, State.Constraint.TOP_TO_TOP);
applyConnection(this.mConstraintWidget, this.mTopToBottom, State.Constraint.TOP_TO_BOTTOM);
applyConnection(this.mConstraintWidget, this.mBottomToTop, State.Constraint.BOTTOM_TO_TOP);
applyConnection(this.mConstraintWidget, this.mBottomToBottom, State.Constraint.BOTTOM_TO_BOTTOM);
applyConnection(this.mConstraintWidget, this.mBaselineToBaseline, State.Constraint.BASELINE_TO_BASELINE);
int i = this.mHorizontalChainStyle;
if (i != 0) {
this.mConstraintWidget.setHorizontalChainStyle(i);
}
int i2 = this.mVerticalChainStyle;
if (i2 != 0) {
this.mConstraintWidget.setVerticalChainStyle(i2);
}
this.mConstraintWidget.setHorizontalBiasPercent(this.mHorizontalBias);
this.mConstraintWidget.setVerticalBiasPercent(this.mVerticalBias);
}
}
public ConstraintReference baseline() {
this.mLast = State.Constraint.BASELINE_TO_BASELINE;
return this;
}
public ConstraintReference baselineToBaseline(Object obj) {
this.mLast = State.Constraint.BASELINE_TO_BASELINE;
this.mBaselineToBaseline = obj;
return this;
}
public ConstraintReference bias(float f) {
State.Constraint constraint = this.mLast;
if (constraint == null) {
return this;
}
switch (constraint.ordinal()) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 13:
this.mHorizontalBias = f;
break;
case 8:
case 9:
case 10:
case 11:
case 14:
this.mVerticalBias = f;
break;
}
return this;
}
public ConstraintReference bottom() {
if (this.mBottomToTop != null) {
this.mLast = State.Constraint.BOTTOM_TO_TOP;
} else {
this.mLast = State.Constraint.BOTTOM_TO_BOTTOM;
}
return this;
}
public ConstraintReference bottomToBottom(Object obj) {
this.mLast = State.Constraint.BOTTOM_TO_BOTTOM;
this.mBottomToBottom = obj;
return this;
}
public ConstraintReference bottomToTop(Object obj) {
this.mLast = State.Constraint.BOTTOM_TO_TOP;
this.mBottomToTop = obj;
return this;
}
public ConstraintReference centerHorizontally(Object obj) {
Object obj2 = get(obj);
this.mStartToStart = obj2;
this.mEndToEnd = obj2;
this.mLast = State.Constraint.CENTER_HORIZONTALLY;
this.mHorizontalBias = 0.5f;
return this;
}
public ConstraintReference centerVertically(Object obj) {
Object obj2 = get(obj);
this.mTopToTop = obj2;
this.mBottomToBottom = obj2;
this.mLast = State.Constraint.CENTER_VERTICALLY;
this.mVerticalBias = 0.5f;
return this;
}
public ConstraintReference clear() {
State.Constraint constraint = this.mLast;
if (constraint != null) {
switch (constraint.ordinal()) {
case 0:
case 1:
this.mLeftToLeft = null;
this.mLeftToRight = null;
this.mMarginLeft = 0;
this.mMarginLeftGone = 0;
break;
case 2:
case 3:
this.mRightToLeft = null;
this.mRightToRight = null;
this.mMarginRight = 0;
this.mMarginRightGone = 0;
break;
case 4:
case 5:
this.mStartToStart = null;
this.mStartToEnd = null;
this.mMarginStart = 0;
this.mMarginStartGone = 0;
break;
case 6:
case 7:
this.mEndToStart = null;
this.mEndToEnd = null;
this.mMarginEnd = 0;
this.mMarginEndGone = 0;
break;
case 8:
case 9:
this.mTopToTop = null;
this.mTopToBottom = null;
this.mMarginTop = 0;
this.mMarginTopGone = 0;
break;
case 10:
case 11:
this.mBottomToTop = null;
this.mBottomToBottom = null;
this.mMarginBottom = 0;
this.mMarginBottomGone = 0;
break;
case 12:
this.mBaselineToBaseline = null;
break;
}
} else {
this.mLeftToLeft = null;
this.mLeftToRight = null;
this.mMarginLeft = 0;
this.mRightToLeft = null;
this.mRightToRight = null;
this.mMarginRight = 0;
this.mStartToStart = null;
this.mStartToEnd = null;
this.mMarginStart = 0;
this.mEndToStart = null;
this.mEndToEnd = null;
this.mMarginEnd = 0;
this.mTopToTop = null;
this.mTopToBottom = null;
this.mMarginTop = 0;
this.mBottomToTop = null;
this.mBottomToBottom = null;
this.mMarginBottom = 0;
this.mBaselineToBaseline = null;
this.mHorizontalBias = 0.5f;
this.mVerticalBias = 0.5f;
this.mMarginLeftGone = 0;
this.mMarginRightGone = 0;
this.mMarginStartGone = 0;
this.mMarginEndGone = 0;
this.mMarginTopGone = 0;
this.mMarginBottomGone = 0;
}
return this;
}
public ConstraintReference clearHorizontal() {
start().clear();
end().clear();
left().clear();
right().clear();
return this;
}
public ConstraintReference clearVertical() {
top().clear();
baseline().clear();
bottom().clear();
return this;
}
public ConstraintWidget createConstraintWidget() {
return new ConstraintWidget(getWidth().getValue(), getHeight().getValue());
}
public ConstraintReference end() {
if (this.mEndToStart != null) {
this.mLast = State.Constraint.END_TO_START;
} else {
this.mLast = State.Constraint.END_TO_END;
}
return this;
}
public ConstraintReference endToEnd(Object obj) {
this.mLast = State.Constraint.END_TO_END;
this.mEndToEnd = obj;
return this;
}
public ConstraintReference endToStart(Object obj) {
this.mLast = State.Constraint.END_TO_START;
this.mEndToStart = obj;
return this;
}
@Override // androidx.constraintlayout.solver.state.Reference
public ConstraintWidget getConstraintWidget() {
if (this.mConstraintWidget == null) {
ConstraintWidget createConstraintWidget = createConstraintWidget();
this.mConstraintWidget = createConstraintWidget;
createConstraintWidget.setCompanionWidget(this.mView);
}
return this.mConstraintWidget;
}
public Dimension getHeight() {
return this.mVerticalDimension;
}
public int getHorizontalChainStyle() {
return this.mHorizontalChainStyle;
}
@Override // androidx.constraintlayout.solver.state.Reference
public Object getKey() {
return this.key;
}
public int getVerticalChainStyle(int i) {
return this.mVerticalChainStyle;
}
public Object getView() {
return this.mView;
}
public Dimension getWidth() {
return this.mHorizontalDimension;
}
public ConstraintReference height(Dimension dimension) {
return setHeight(dimension);
}
public ConstraintReference horizontalBias(float f) {
this.mHorizontalBias = f;
return this;
}
public ConstraintReference left() {
if (this.mLeftToLeft != null) {
this.mLast = State.Constraint.LEFT_TO_LEFT;
} else {
this.mLast = State.Constraint.LEFT_TO_RIGHT;
}
return this;
}
public ConstraintReference leftToLeft(Object obj) {
this.mLast = State.Constraint.LEFT_TO_LEFT;
this.mLeftToLeft = obj;
return this;
}
public ConstraintReference leftToRight(Object obj) {
this.mLast = State.Constraint.LEFT_TO_RIGHT;
this.mLeftToRight = obj;
return this;
}
public ConstraintReference margin(int i) {
State.Constraint constraint = this.mLast;
if (constraint != null) {
switch (constraint.ordinal()) {
case 0:
case 1:
this.mMarginLeft = i;
break;
case 2:
case 3:
this.mMarginRight = i;
break;
case 4:
case 5:
this.mMarginStart = i;
break;
case 6:
case 7:
this.mMarginEnd = i;
break;
case 8:
case 9:
this.mMarginTop = i;
break;
case 10:
case 11:
this.mMarginBottom = i;
break;
}
} else {
this.mMarginLeft = i;
this.mMarginRight = i;
this.mMarginStart = i;
this.mMarginEnd = i;
this.mMarginTop = i;
this.mMarginBottom = i;
}
return this;
}
public ConstraintReference margin(Object obj) {
return margin(this.mState.convertDimension(obj));
}
public ConstraintReference marginGone(int i) {
State.Constraint constraint = this.mLast;
if (constraint != null) {
switch (constraint.ordinal()) {
case 0:
case 1:
this.mMarginLeftGone = i;
break;
case 2:
case 3:
this.mMarginRightGone = i;
break;
case 4:
case 5:
this.mMarginStartGone = i;
break;
case 6:
case 7:
this.mMarginEndGone = i;
break;
case 8:
case 9:
this.mMarginTopGone = i;
break;
case 10:
case 11:
this.mMarginBottomGone = i;
break;
}
} else {
this.mMarginLeftGone = i;
this.mMarginRightGone = i;
this.mMarginStartGone = i;
this.mMarginEndGone = i;
this.mMarginTopGone = i;
this.mMarginBottomGone = i;
}
return this;
}
public ConstraintReference right() {
if (this.mRightToLeft != null) {
this.mLast = State.Constraint.RIGHT_TO_LEFT;
} else {
this.mLast = State.Constraint.RIGHT_TO_RIGHT;
}
return this;
}
public ConstraintReference rightToLeft(Object obj) {
this.mLast = State.Constraint.RIGHT_TO_LEFT;
this.mRightToLeft = obj;
return this;
}
public ConstraintReference rightToRight(Object obj) {
this.mLast = State.Constraint.RIGHT_TO_RIGHT;
this.mRightToRight = obj;
return this;
}
@Override // androidx.constraintlayout.solver.state.Reference
public void setConstraintWidget(ConstraintWidget constraintWidget) {
if (constraintWidget != null) {
this.mConstraintWidget = constraintWidget;
constraintWidget.setCompanionWidget(this.mView);
}
}
public ConstraintReference setHeight(Dimension dimension) {
this.mVerticalDimension = dimension;
return this;
}
public void setHorizontalChainStyle(int i) {
this.mHorizontalChainStyle = i;
}
@Override // androidx.constraintlayout.solver.state.Reference
public void setKey(Object obj) {
this.key = obj;
}
public void setVerticalChainStyle(int i) {
this.mVerticalChainStyle = i;
}
public void setView(Object obj) {
this.mView = obj;
ConstraintWidget constraintWidget = this.mConstraintWidget;
if (constraintWidget != null) {
constraintWidget.setCompanionWidget(obj);
}
}
public ConstraintReference setWidth(Dimension dimension) {
this.mHorizontalDimension = dimension;
return this;
}
public ConstraintReference start() {
if (this.mStartToStart != null) {
this.mLast = State.Constraint.START_TO_START;
} else {
this.mLast = State.Constraint.START_TO_END;
}
return this;
}
public ConstraintReference startToEnd(Object obj) {
this.mLast = State.Constraint.START_TO_END;
this.mStartToEnd = obj;
return this;
}
public ConstraintReference startToStart(Object obj) {
this.mLast = State.Constraint.START_TO_START;
this.mStartToStart = obj;
return this;
}
public ConstraintReference top() {
if (this.mTopToTop != null) {
this.mLast = State.Constraint.TOP_TO_TOP;
} else {
this.mLast = State.Constraint.TOP_TO_BOTTOM;
}
return this;
}
public ConstraintReference topToBottom(Object obj) {
this.mLast = State.Constraint.TOP_TO_BOTTOM;
this.mTopToBottom = obj;
return this;
}
public ConstraintReference topToTop(Object obj) {
this.mLast = State.Constraint.TOP_TO_TOP;
this.mTopToTop = obj;
return this;
}
public void validate() throws IncorrectConstraintException {
ArrayList arrayList = new ArrayList();
if (!(this.mLeftToLeft == null || this.mLeftToRight == null)) {
arrayList.add("LeftToLeft and LeftToRight both defined");
}
if (!(this.mRightToLeft == null || this.mRightToRight == null)) {
arrayList.add("RightToLeft and RightToRight both defined");
}
if (!(this.mStartToStart == null || this.mStartToEnd == null)) {
arrayList.add("StartToStart and StartToEnd both defined");
}
if (!(this.mEndToStart == null || this.mEndToEnd == null)) {
arrayList.add("EndToStart and EndToEnd both defined");
}
if (!((this.mLeftToLeft == null && this.mLeftToRight == null && this.mRightToLeft == null && this.mRightToRight == null) || (this.mStartToStart == null && this.mStartToEnd == null && this.mEndToStart == null && this.mEndToEnd == null))) {
arrayList.add("Both left/right and start/end constraints defined");
}
if (arrayList.size() > 0) {
throw new IncorrectConstraintException(arrayList);
}
}
public ConstraintReference verticalBias(float f) {
this.mVerticalBias = f;
return this;
}
public ConstraintReference width(Dimension dimension) {
return setWidth(dimension);
}
}