278 lines
11 KiB
Java
278 lines
11 KiB
Java
package androidx.constraintlayout.solver.widgets.analyzer;
|
|
|
|
import androidx.constraintlayout.solver.widgets.ConstraintAnchor;
|
|
import androidx.constraintlayout.solver.widgets.ConstraintWidget;
|
|
public abstract class WidgetRun implements Dependency {
|
|
public DimensionDependency dimension = new DimensionDependency(this);
|
|
public ConstraintWidget.DimensionBehaviour dimensionBehavior;
|
|
public DependencyNode end = new DependencyNode(this);
|
|
public RunType mRunType = RunType.NONE;
|
|
public int matchConstraintsType;
|
|
public int orientation = 0;
|
|
public boolean resolved = false;
|
|
public RunGroup runGroup;
|
|
public DependencyNode start = new DependencyNode(this);
|
|
public ConstraintWidget widget;
|
|
|
|
/* renamed from: androidx.constraintlayout.solver.widgets.analyzer.WidgetRun$1 reason: invalid class name */
|
|
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.BASELINE.ordinal()] = 4;
|
|
} catch (NoSuchFieldError unused4) {
|
|
}
|
|
try {
|
|
$SwitchMap$androidx$constraintlayout$solver$widgets$ConstraintAnchor$Type[ConstraintAnchor.Type.BOTTOM.ordinal()] = 5;
|
|
} catch (NoSuchFieldError unused5) {
|
|
}
|
|
}
|
|
}
|
|
|
|
public enum RunType {
|
|
NONE,
|
|
START,
|
|
END,
|
|
CENTER
|
|
}
|
|
|
|
public WidgetRun(ConstraintWidget constraintWidget) {
|
|
this.widget = constraintWidget;
|
|
}
|
|
|
|
private void resolveDimension(int i, int i2) {
|
|
int i3 = this.matchConstraintsType;
|
|
if (i3 == 0) {
|
|
this.dimension.resolve(getLimitedDimension(i2, i));
|
|
} else if (i3 == 1) {
|
|
this.dimension.resolve(Math.min(getLimitedDimension(this.dimension.wrapValue, i), i2));
|
|
} else if (i3 == 2) {
|
|
ConstraintWidget parent = this.widget.getParent();
|
|
if (parent != null) {
|
|
DimensionDependency dimensionDependency = (i == 0 ? parent.horizontalRun : parent.verticalRun).dimension;
|
|
if (dimensionDependency.resolved) {
|
|
ConstraintWidget constraintWidget = this.widget;
|
|
this.dimension.resolve(getLimitedDimension((int) ((((float) dimensionDependency.value) * (i == 0 ? constraintWidget.mMatchConstraintPercentWidth : constraintWidget.mMatchConstraintPercentHeight)) + 0.5f), i));
|
|
}
|
|
}
|
|
} else if (i3 == 3) {
|
|
ConstraintWidget constraintWidget2 = this.widget;
|
|
WidgetRun widgetRun = constraintWidget2.horizontalRun;
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour = widgetRun.dimensionBehavior;
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour2 = ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT;
|
|
if (dimensionBehaviour == dimensionBehaviour2 && widgetRun.matchConstraintsType == 3) {
|
|
VerticalWidgetRun verticalWidgetRun = constraintWidget2.verticalRun;
|
|
if (verticalWidgetRun.dimensionBehavior == dimensionBehaviour2 && verticalWidgetRun.matchConstraintsType == 3) {
|
|
return;
|
|
}
|
|
}
|
|
if (i == 0) {
|
|
widgetRun = constraintWidget2.verticalRun;
|
|
}
|
|
if (widgetRun.dimension.resolved) {
|
|
float dimensionRatio = constraintWidget2.getDimensionRatio();
|
|
this.dimension.resolve(i == 1 ? (int) ((((float) widgetRun.dimension.value) / dimensionRatio) + 0.5f) : (int) ((dimensionRatio * ((float) widgetRun.dimension.value)) + 0.5f));
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void addTarget(DependencyNode dependencyNode, DependencyNode dependencyNode2, int i) {
|
|
dependencyNode.targets.add(dependencyNode2);
|
|
dependencyNode.margin = i;
|
|
dependencyNode2.dependencies.add(dependencyNode);
|
|
}
|
|
|
|
public final void addTarget(DependencyNode dependencyNode, DependencyNode dependencyNode2, int i, DimensionDependency dimensionDependency) {
|
|
dependencyNode.targets.add(dependencyNode2);
|
|
dependencyNode.targets.add(this.dimension);
|
|
dependencyNode.marginFactor = i;
|
|
dependencyNode.marginDependency = dimensionDependency;
|
|
dependencyNode2.dependencies.add(dependencyNode);
|
|
dimensionDependency.dependencies.add(dependencyNode);
|
|
}
|
|
|
|
public abstract void apply();
|
|
|
|
public abstract void applyToWidget();
|
|
|
|
public abstract void clear();
|
|
|
|
public final int getLimitedDimension(int i, int i2) {
|
|
int i3;
|
|
if (i2 == 0) {
|
|
ConstraintWidget constraintWidget = this.widget;
|
|
int i4 = constraintWidget.mMatchConstraintMaxWidth;
|
|
i3 = Math.max(constraintWidget.mMatchConstraintMinWidth, i);
|
|
if (i4 > 0) {
|
|
i3 = Math.min(i4, i);
|
|
}
|
|
if (i3 == i) {
|
|
return i;
|
|
}
|
|
} else {
|
|
ConstraintWidget constraintWidget2 = this.widget;
|
|
int i5 = constraintWidget2.mMatchConstraintMaxHeight;
|
|
i3 = Math.max(constraintWidget2.mMatchConstraintMinHeight, i);
|
|
if (i5 > 0) {
|
|
i3 = Math.min(i5, i);
|
|
}
|
|
if (i3 == i) {
|
|
return i;
|
|
}
|
|
}
|
|
return i3;
|
|
}
|
|
|
|
public final DependencyNode getTarget(ConstraintAnchor constraintAnchor) {
|
|
ConstraintAnchor constraintAnchor2 = constraintAnchor.mTarget;
|
|
if (constraintAnchor2 == null) {
|
|
return null;
|
|
}
|
|
ConstraintWidget constraintWidget = constraintAnchor2.mOwner;
|
|
int ordinal = constraintAnchor2.mType.ordinal();
|
|
if (ordinal == 1) {
|
|
return constraintWidget.horizontalRun.start;
|
|
}
|
|
if (ordinal == 2) {
|
|
return constraintWidget.verticalRun.start;
|
|
}
|
|
if (ordinal == 3) {
|
|
return constraintWidget.horizontalRun.end;
|
|
}
|
|
if (ordinal == 4) {
|
|
return constraintWidget.verticalRun.end;
|
|
}
|
|
if (ordinal != 5) {
|
|
return null;
|
|
}
|
|
return constraintWidget.verticalRun.baseline;
|
|
}
|
|
|
|
public final DependencyNode getTarget(ConstraintAnchor constraintAnchor, int i) {
|
|
ConstraintAnchor constraintAnchor2 = constraintAnchor.mTarget;
|
|
if (constraintAnchor2 == null) {
|
|
return null;
|
|
}
|
|
ConstraintWidget constraintWidget = constraintAnchor2.mOwner;
|
|
WidgetRun widgetRun = i == 0 ? constraintWidget.horizontalRun : constraintWidget.verticalRun;
|
|
int ordinal = constraintAnchor2.mType.ordinal();
|
|
if (ordinal == 1 || ordinal == 2) {
|
|
return widgetRun.start;
|
|
}
|
|
if (ordinal == 3 || ordinal == 4) {
|
|
return widgetRun.end;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public long getWrapDimension() {
|
|
DimensionDependency dimensionDependency = this.dimension;
|
|
if (dimensionDependency.resolved) {
|
|
return (long) dimensionDependency.value;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public boolean isCenterConnection() {
|
|
int size = this.start.targets.size();
|
|
int i = 0;
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
if (this.start.targets.get(i2).run != this) {
|
|
i++;
|
|
}
|
|
}
|
|
int size2 = this.end.targets.size();
|
|
for (int i3 = 0; i3 < size2; i3++) {
|
|
if (this.end.targets.get(i3).run != this) {
|
|
i++;
|
|
}
|
|
}
|
|
return i >= 2;
|
|
}
|
|
|
|
public boolean isDimensionResolved() {
|
|
return this.dimension.resolved;
|
|
}
|
|
|
|
public boolean isResolved() {
|
|
return this.resolved;
|
|
}
|
|
|
|
public abstract void reset();
|
|
|
|
public abstract boolean supportsWrapComputation();
|
|
|
|
@Override // androidx.constraintlayout.solver.widgets.analyzer.Dependency
|
|
public void update(Dependency dependency) {
|
|
}
|
|
|
|
public void updateRunCenter(Dependency dependency, ConstraintAnchor constraintAnchor, ConstraintAnchor constraintAnchor2, int i) {
|
|
DependencyNode target = getTarget(constraintAnchor);
|
|
DependencyNode target2 = getTarget(constraintAnchor2);
|
|
if (target.resolved && target2.resolved) {
|
|
int margin = constraintAnchor.getMargin() + target.value;
|
|
int margin2 = target2.value - constraintAnchor2.getMargin();
|
|
int i2 = margin2 - margin;
|
|
if (!this.dimension.resolved && this.dimensionBehavior == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT) {
|
|
resolveDimension(i, i2);
|
|
}
|
|
DimensionDependency dimensionDependency = this.dimension;
|
|
if (dimensionDependency.resolved) {
|
|
if (dimensionDependency.value == i2) {
|
|
this.start.resolve(margin);
|
|
this.end.resolve(margin2);
|
|
return;
|
|
}
|
|
ConstraintWidget constraintWidget = this.widget;
|
|
float horizontalBiasPercent = i == 0 ? constraintWidget.getHorizontalBiasPercent() : constraintWidget.getVerticalBiasPercent();
|
|
if (target == target2) {
|
|
margin = target.value;
|
|
margin2 = target2.value;
|
|
horizontalBiasPercent = 0.5f;
|
|
}
|
|
this.start.resolve((int) ((((float) ((margin2 - margin) - this.dimension.value)) * horizontalBiasPercent) + ((float) margin) + 0.5f));
|
|
this.end.resolve(this.start.value + this.dimension.value);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void updateRunEnd(Dependency dependency) {
|
|
}
|
|
|
|
public void updateRunStart(Dependency dependency) {
|
|
}
|
|
|
|
public long wrapSize(int i) {
|
|
int i2;
|
|
DimensionDependency dimensionDependency = this.dimension;
|
|
if (!dimensionDependency.resolved) {
|
|
return 0;
|
|
}
|
|
long j = (long) dimensionDependency.value;
|
|
if (isCenterConnection()) {
|
|
i2 = this.start.margin - this.end.margin;
|
|
} else if (i != 0) {
|
|
return j - ((long) this.end.margin);
|
|
} else {
|
|
i2 = this.start.margin;
|
|
}
|
|
return j + ((long) i2);
|
|
}
|
|
}
|