2021-06-27 20:44:35 +00:00
|
|
|
package androidx.constraintlayout.solver.widgets.analyzer;
|
|
|
|
|
|
|
|
import androidx.constraintlayout.solver.widgets.Barrier;
|
|
|
|
import androidx.constraintlayout.solver.widgets.ConstraintAnchor;
|
|
|
|
import androidx.constraintlayout.solver.widgets.ConstraintWidget;
|
|
|
|
import androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer;
|
|
|
|
import androidx.constraintlayout.solver.widgets.Guideline;
|
|
|
|
import androidx.constraintlayout.solver.widgets.HelperWidget;
|
|
|
|
import androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure;
|
|
|
|
import c.d.b.a.a;
|
|
|
|
import java.io.PrintStream;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Iterator;
|
|
|
|
public class DependencyGraph {
|
|
|
|
private static final boolean USE_GROUPS = true;
|
|
|
|
private ConstraintWidgetContainer container;
|
|
|
|
private ConstraintWidgetContainer mContainer;
|
|
|
|
public ArrayList<RunGroup> mGroups = new ArrayList<>();
|
|
|
|
private BasicMeasure.Measure mMeasure = new BasicMeasure.Measure();
|
|
|
|
private BasicMeasure.Measurer mMeasurer = null;
|
|
|
|
private boolean mNeedBuildGraph = true;
|
|
|
|
private boolean mNeedRedoMeasures = true;
|
|
|
|
private ArrayList<WidgetRun> mRuns = new ArrayList<>();
|
|
|
|
private ArrayList<RunGroup> runGroups = new ArrayList<>();
|
|
|
|
|
|
|
|
public DependencyGraph(ConstraintWidgetContainer constraintWidgetContainer) {
|
|
|
|
this.container = constraintWidgetContainer;
|
|
|
|
this.mContainer = constraintWidgetContainer;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void applyGroup(DependencyNode dependencyNode, int i, int i2, DependencyNode dependencyNode2, ArrayList<RunGroup> arrayList, RunGroup runGroup) {
|
|
|
|
WidgetRun widgetRun = dependencyNode.run;
|
|
|
|
if (widgetRun.runGroup == null) {
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer = this.container;
|
|
|
|
if (!(widgetRun == constraintWidgetContainer.horizontalRun || widgetRun == constraintWidgetContainer.verticalRun)) {
|
|
|
|
if (runGroup == null) {
|
|
|
|
runGroup = new RunGroup(widgetRun, i2);
|
|
|
|
arrayList.add(runGroup);
|
|
|
|
}
|
|
|
|
widgetRun.runGroup = runGroup;
|
|
|
|
runGroup.add(widgetRun);
|
|
|
|
for (Dependency dependency : widgetRun.start.dependencies) {
|
|
|
|
if (dependency instanceof DependencyNode) {
|
|
|
|
applyGroup((DependencyNode) dependency, i, 0, dependencyNode2, arrayList, runGroup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (Dependency dependency2 : widgetRun.end.dependencies) {
|
|
|
|
if (dependency2 instanceof DependencyNode) {
|
|
|
|
applyGroup((DependencyNode) dependency2, i, 1, dependencyNode2, arrayList, runGroup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == 1 && (widgetRun instanceof VerticalWidgetRun)) {
|
|
|
|
for (Dependency dependency3 : ((VerticalWidgetRun) widgetRun).baseline.dependencies) {
|
|
|
|
if (dependency3 instanceof DependencyNode) {
|
|
|
|
applyGroup((DependencyNode) dependency3, i, 2, dependencyNode2, arrayList, runGroup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (DependencyNode dependencyNode3 : widgetRun.start.targets) {
|
|
|
|
if (dependencyNode3 == dependencyNode2) {
|
|
|
|
runGroup.dual = true;
|
|
|
|
}
|
|
|
|
applyGroup(dependencyNode3, i, 0, dependencyNode2, arrayList, runGroup);
|
|
|
|
}
|
|
|
|
for (DependencyNode dependencyNode4 : widgetRun.end.targets) {
|
|
|
|
if (dependencyNode4 == dependencyNode2) {
|
|
|
|
runGroup.dual = true;
|
|
|
|
}
|
|
|
|
applyGroup(dependencyNode4, i, 1, dependencyNode2, arrayList, runGroup);
|
|
|
|
}
|
|
|
|
if (i == 1 && (widgetRun instanceof VerticalWidgetRun)) {
|
|
|
|
for (DependencyNode dependencyNode5 : ((VerticalWidgetRun) widgetRun).baseline.targets) {
|
|
|
|
applyGroup(dependencyNode5, i, 2, dependencyNode2, arrayList, runGroup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean basicMeasureWidgets(ConstraintWidgetContainer constraintWidgetContainer) {
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour;
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour2;
|
|
|
|
int i;
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour3;
|
|
|
|
int i2;
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour4;
|
|
|
|
Iterator<ConstraintWidget> it = constraintWidgetContainer.mChildren.iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
ConstraintWidget next = it.next();
|
|
|
|
ConstraintWidget.DimensionBehaviour[] dimensionBehaviourArr = next.mListDimensionBehaviors;
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour5 = dimensionBehaviourArr[0];
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour6 = dimensionBehaviourArr[1];
|
|
|
|
if (next.getVisibility() == 8) {
|
|
|
|
next.measured = true;
|
|
|
|
} else {
|
|
|
|
if (next.mMatchConstraintPercentWidth < 1.0f && dimensionBehaviour5 == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT) {
|
|
|
|
next.mMatchConstraintDefaultWidth = 2;
|
|
|
|
}
|
|
|
|
if (next.mMatchConstraintPercentHeight < 1.0f && dimensionBehaviour6 == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT) {
|
|
|
|
next.mMatchConstraintDefaultHeight = 2;
|
|
|
|
}
|
|
|
|
if (next.getDimensionRatio() > 0.0f) {
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour7 = ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT;
|
|
|
|
if (dimensionBehaviour5 == dimensionBehaviour7 && (dimensionBehaviour6 == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT || dimensionBehaviour6 == ConstraintWidget.DimensionBehaviour.FIXED)) {
|
|
|
|
next.mMatchConstraintDefaultWidth = 3;
|
|
|
|
} else if (dimensionBehaviour6 == dimensionBehaviour7 && (dimensionBehaviour5 == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT || dimensionBehaviour5 == ConstraintWidget.DimensionBehaviour.FIXED)) {
|
|
|
|
next.mMatchConstraintDefaultHeight = 3;
|
|
|
|
} else if (dimensionBehaviour5 == dimensionBehaviour7 && dimensionBehaviour6 == dimensionBehaviour7) {
|
|
|
|
if (next.mMatchConstraintDefaultWidth == 0) {
|
|
|
|
next.mMatchConstraintDefaultWidth = 3;
|
|
|
|
}
|
|
|
|
if (next.mMatchConstraintDefaultHeight == 0) {
|
|
|
|
next.mMatchConstraintDefaultHeight = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour8 = ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT;
|
|
|
|
if (dimensionBehaviour5 == dimensionBehaviour8 && next.mMatchConstraintDefaultWidth == 1 && (next.mLeft.mTarget == null || next.mRight.mTarget == null)) {
|
|
|
|
dimensionBehaviour5 = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
|
|
|
}
|
|
|
|
if (dimensionBehaviour6 == dimensionBehaviour8 && next.mMatchConstraintDefaultHeight == 1 && (next.mTop.mTarget == null || next.mBottom.mTarget == null)) {
|
|
|
|
dimensionBehaviour6 = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
|
|
|
}
|
|
|
|
HorizontalWidgetRun horizontalWidgetRun = next.horizontalRun;
|
|
|
|
horizontalWidgetRun.dimensionBehavior = dimensionBehaviour5;
|
|
|
|
int i3 = next.mMatchConstraintDefaultWidth;
|
|
|
|
horizontalWidgetRun.matchConstraintsType = i3;
|
|
|
|
VerticalWidgetRun verticalWidgetRun = next.verticalRun;
|
|
|
|
verticalWidgetRun.dimensionBehavior = dimensionBehaviour6;
|
|
|
|
int i4 = next.mMatchConstraintDefaultHeight;
|
|
|
|
verticalWidgetRun.matchConstraintsType = i4;
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour9 = ConstraintWidget.DimensionBehaviour.MATCH_PARENT;
|
|
|
|
if ((dimensionBehaviour5 == dimensionBehaviour9 || dimensionBehaviour5 == ConstraintWidget.DimensionBehaviour.FIXED || dimensionBehaviour5 == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT) && (dimensionBehaviour6 == dimensionBehaviour9 || dimensionBehaviour6 == ConstraintWidget.DimensionBehaviour.FIXED || dimensionBehaviour6 == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT)) {
|
|
|
|
int width = next.getWidth();
|
|
|
|
if (dimensionBehaviour5 == dimensionBehaviour9) {
|
|
|
|
i = (constraintWidgetContainer.getWidth() - next.mLeft.mMargin) - next.mRight.mMargin;
|
|
|
|
dimensionBehaviour3 = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
|
|
} else {
|
|
|
|
i = width;
|
|
|
|
dimensionBehaviour3 = dimensionBehaviour5;
|
|
|
|
}
|
|
|
|
int height = next.getHeight();
|
|
|
|
if (dimensionBehaviour6 == dimensionBehaviour9) {
|
|
|
|
i2 = (constraintWidgetContainer.getHeight() - next.mTop.mMargin) - next.mBottom.mMargin;
|
|
|
|
dimensionBehaviour4 = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
|
|
} else {
|
|
|
|
i2 = height;
|
|
|
|
dimensionBehaviour4 = dimensionBehaviour6;
|
|
|
|
}
|
|
|
|
measure(next, dimensionBehaviour3, i, dimensionBehaviour4, i2);
|
|
|
|
next.horizontalRun.dimension.resolve(next.getWidth());
|
|
|
|
next.verticalRun.dimension.resolve(next.getHeight());
|
|
|
|
next.measured = true;
|
|
|
|
} else {
|
|
|
|
if (dimensionBehaviour5 == dimensionBehaviour8 && (dimensionBehaviour6 == (dimensionBehaviour2 = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT) || dimensionBehaviour6 == ConstraintWidget.DimensionBehaviour.FIXED)) {
|
|
|
|
if (i3 == 3) {
|
|
|
|
if (dimensionBehaviour6 == dimensionBehaviour2) {
|
|
|
|
measure(next, dimensionBehaviour2, 0, dimensionBehaviour2, 0);
|
|
|
|
}
|
|
|
|
int height2 = next.getHeight();
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour10 = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
|
|
measure(next, dimensionBehaviour10, (int) ((((float) height2) * next.mDimensionRatio) + 0.5f), dimensionBehaviour10, height2);
|
|
|
|
next.horizontalRun.dimension.resolve(next.getWidth());
|
|
|
|
next.verticalRun.dimension.resolve(next.getHeight());
|
|
|
|
next.measured = true;
|
|
|
|
} else if (i3 == 1) {
|
|
|
|
measure(next, dimensionBehaviour2, 0, dimensionBehaviour6, 0);
|
|
|
|
next.horizontalRun.dimension.wrapValue = next.getWidth();
|
|
|
|
} else if (i3 == 2) {
|
|
|
|
ConstraintWidget.DimensionBehaviour[] dimensionBehaviourArr2 = constraintWidgetContainer.mListDimensionBehaviors;
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour11 = dimensionBehaviourArr2[0];
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour12 = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
|
|
if (dimensionBehaviour11 == dimensionBehaviour12 || dimensionBehaviourArr2[0] == dimensionBehaviour9) {
|
|
|
|
measure(next, dimensionBehaviour12, (int) ((next.mMatchConstraintPercentWidth * ((float) constraintWidgetContainer.getWidth())) + 0.5f), dimensionBehaviour6, next.getHeight());
|
|
|
|
next.horizontalRun.dimension.resolve(next.getWidth());
|
|
|
|
next.verticalRun.dimension.resolve(next.getHeight());
|
|
|
|
next.measured = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ConstraintAnchor[] constraintAnchorArr = next.mListAnchors;
|
|
|
|
if (constraintAnchorArr[0].mTarget == null || constraintAnchorArr[1].mTarget == null) {
|
|
|
|
measure(next, dimensionBehaviour2, 0, dimensionBehaviour6, 0);
|
|
|
|
next.horizontalRun.dimension.resolve(next.getWidth());
|
|
|
|
next.verticalRun.dimension.resolve(next.getHeight());
|
|
|
|
next.measured = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dimensionBehaviour6 == dimensionBehaviour8 && (dimensionBehaviour5 == (dimensionBehaviour = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT) || dimensionBehaviour5 == ConstraintWidget.DimensionBehaviour.FIXED)) {
|
|
|
|
if (i4 == 3) {
|
|
|
|
if (dimensionBehaviour5 == dimensionBehaviour) {
|
|
|
|
measure(next, dimensionBehaviour, 0, dimensionBehaviour, 0);
|
|
|
|
}
|
|
|
|
int width2 = next.getWidth();
|
|
|
|
float f = next.mDimensionRatio;
|
|
|
|
if (next.getDimensionRatioSide() == -1) {
|
|
|
|
f = 1.0f / f;
|
|
|
|
}
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour13 = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
|
|
measure(next, dimensionBehaviour13, width2, dimensionBehaviour13, (int) ((((float) width2) * f) + 0.5f));
|
|
|
|
next.horizontalRun.dimension.resolve(next.getWidth());
|
|
|
|
next.verticalRun.dimension.resolve(next.getHeight());
|
|
|
|
next.measured = true;
|
|
|
|
} else if (i4 == 1) {
|
|
|
|
measure(next, dimensionBehaviour5, 0, dimensionBehaviour, 0);
|
|
|
|
next.verticalRun.dimension.wrapValue = next.getHeight();
|
|
|
|
} else if (i4 == 2) {
|
|
|
|
ConstraintWidget.DimensionBehaviour[] dimensionBehaviourArr3 = constraintWidgetContainer.mListDimensionBehaviors;
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour14 = dimensionBehaviourArr3[1];
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour15 = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
|
|
if (dimensionBehaviour14 == dimensionBehaviour15 || dimensionBehaviourArr3[1] == dimensionBehaviour9) {
|
|
|
|
measure(next, dimensionBehaviour5, next.getWidth(), dimensionBehaviour15, (int) ((next.mMatchConstraintPercentHeight * ((float) constraintWidgetContainer.getHeight())) + 0.5f));
|
|
|
|
next.horizontalRun.dimension.resolve(next.getWidth());
|
|
|
|
next.verticalRun.dimension.resolve(next.getHeight());
|
|
|
|
next.measured = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ConstraintAnchor[] constraintAnchorArr2 = next.mListAnchors;
|
|
|
|
if (constraintAnchorArr2[2].mTarget == null || constraintAnchorArr2[3].mTarget == null) {
|
|
|
|
measure(next, dimensionBehaviour, 0, dimensionBehaviour6, 0);
|
|
|
|
next.horizontalRun.dimension.resolve(next.getWidth());
|
|
|
|
next.verticalRun.dimension.resolve(next.getHeight());
|
|
|
|
next.measured = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dimensionBehaviour5 == dimensionBehaviour8 && dimensionBehaviour6 == dimensionBehaviour8) {
|
|
|
|
if (i3 == 1 || i4 == 1) {
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour16 = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
|
|
|
measure(next, dimensionBehaviour16, 0, dimensionBehaviour16, 0);
|
|
|
|
next.horizontalRun.dimension.wrapValue = next.getWidth();
|
|
|
|
next.verticalRun.dimension.wrapValue = next.getHeight();
|
|
|
|
} else if (i4 == 2 && i3 == 2) {
|
|
|
|
ConstraintWidget.DimensionBehaviour[] dimensionBehaviourArr4 = constraintWidgetContainer.mListDimensionBehaviors;
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour17 = dimensionBehaviourArr4[0];
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour18 = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
|
|
if (dimensionBehaviour17 == dimensionBehaviour18 || dimensionBehaviourArr4[0] == dimensionBehaviour18) {
|
|
|
|
if (dimensionBehaviourArr4[1] == dimensionBehaviour18 || dimensionBehaviourArr4[1] == dimensionBehaviour18) {
|
|
|
|
measure(next, dimensionBehaviour18, (int) ((next.mMatchConstraintPercentWidth * ((float) constraintWidgetContainer.getWidth())) + 0.5f), dimensionBehaviour18, (int) ((next.mMatchConstraintPercentHeight * ((float) constraintWidgetContainer.getHeight())) + 0.5f));
|
|
|
|
next.horizontalRun.dimension.resolve(next.getWidth());
|
|
|
|
next.verticalRun.dimension.resolve(next.getHeight());
|
|
|
|
next.measured = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private int computeWrap(ConstraintWidgetContainer constraintWidgetContainer, int i) {
|
|
|
|
int size = this.mGroups.size();
|
|
|
|
long j = 0;
|
|
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
|
|
j = Math.max(j, this.mGroups.get(i2).computeWrapSize(constraintWidgetContainer, i));
|
|
|
|
}
|
|
|
|
return (int) j;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void displayGraph() {
|
|
|
|
Iterator<WidgetRun> it = this.mRuns.iterator();
|
|
|
|
String str = "digraph {\n";
|
|
|
|
while (it.hasNext()) {
|
|
|
|
str = generateDisplayGraph(it.next(), str);
|
|
|
|
}
|
2021-07-13 20:23:20 +00:00
|
|
|
String t = a.t(str, "\n}\n");
|
2021-06-27 20:44:35 +00:00
|
|
|
PrintStream printStream = System.out;
|
2021-07-13 20:23:20 +00:00
|
|
|
printStream.println("content:<<\n" + t + "\n>>");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void findGroup(WidgetRun widgetRun, int i, ArrayList<RunGroup> arrayList) {
|
|
|
|
for (Dependency dependency : widgetRun.start.dependencies) {
|
|
|
|
if (dependency instanceof DependencyNode) {
|
|
|
|
applyGroup((DependencyNode) dependency, i, 0, widgetRun.end, arrayList, null);
|
|
|
|
} else if (dependency instanceof WidgetRun) {
|
|
|
|
applyGroup(((WidgetRun) dependency).start, i, 0, widgetRun.end, arrayList, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (Dependency dependency2 : widgetRun.end.dependencies) {
|
|
|
|
if (dependency2 instanceof DependencyNode) {
|
|
|
|
applyGroup((DependencyNode) dependency2, i, 1, widgetRun.start, arrayList, null);
|
|
|
|
} else if (dependency2 instanceof WidgetRun) {
|
|
|
|
applyGroup(((WidgetRun) dependency2).end, i, 1, widgetRun.start, arrayList, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == 1) {
|
|
|
|
for (Dependency dependency3 : ((VerticalWidgetRun) widgetRun).baseline.dependencies) {
|
|
|
|
if (dependency3 instanceof DependencyNode) {
|
|
|
|
applyGroup((DependencyNode) dependency3, i, 2, null, arrayList, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private String generateChainDisplayGraph(ChainRun chainRun, String str) {
|
|
|
|
int i = chainRun.orientation;
|
|
|
|
StringBuilder L = a.L("cluster_");
|
|
|
|
L.append(chainRun.widget.getDebugName());
|
|
|
|
String sb = L.toString();
|
2021-07-13 20:23:20 +00:00
|
|
|
String u = a.u("subgraph ", i == 0 ? a.t(sb, "_h") : a.t(sb, "_v"), " {\n");
|
2021-06-27 20:44:35 +00:00
|
|
|
Iterator<WidgetRun> it = chainRun.widgets.iterator();
|
|
|
|
String str2 = "";
|
|
|
|
while (it.hasNext()) {
|
|
|
|
WidgetRun next = it.next();
|
|
|
|
String debugName = next.widget.getDebugName();
|
2021-07-13 20:23:20 +00:00
|
|
|
u = a.u(u, i == 0 ? a.t(debugName, "_HORIZONTAL") : a.t(debugName, "_VERTICAL"), ";\n");
|
2021-06-27 20:44:35 +00:00
|
|
|
str2 = generateDisplayGraph(next, str2);
|
|
|
|
}
|
2021-07-13 20:23:20 +00:00
|
|
|
return a.u(str, str2, a.t(u, "}\n"));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private String generateDisplayGraph(WidgetRun widgetRun, String str) {
|
|
|
|
boolean z2;
|
|
|
|
DependencyNode dependencyNode = widgetRun.start;
|
|
|
|
DependencyNode dependencyNode2 = widgetRun.end;
|
|
|
|
if (!(widgetRun instanceof HelperReferences) && dependencyNode.dependencies.isEmpty() && (dependencyNode2.dependencies.isEmpty() && dependencyNode.targets.isEmpty()) && dependencyNode2.targets.isEmpty()) {
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
StringBuilder L = a.L(str);
|
|
|
|
L.append(nodeDefinition(widgetRun));
|
|
|
|
String sb = L.toString();
|
|
|
|
boolean isCenteredConnection = isCenteredConnection(dependencyNode, dependencyNode2);
|
|
|
|
String generateDisplayNode = generateDisplayNode(dependencyNode2, isCenteredConnection, generateDisplayNode(dependencyNode, isCenteredConnection, sb));
|
|
|
|
boolean z3 = widgetRun instanceof VerticalWidgetRun;
|
|
|
|
if (z3) {
|
|
|
|
generateDisplayNode = generateDisplayNode(((VerticalWidgetRun) widgetRun).baseline, isCenteredConnection, generateDisplayNode);
|
|
|
|
}
|
|
|
|
if ((widgetRun instanceof HorizontalWidgetRun) || (((z2 = widgetRun instanceof ChainRun)) && ((ChainRun) widgetRun).orientation == 0)) {
|
|
|
|
ConstraintWidget.DimensionBehaviour horizontalDimensionBehaviour = widgetRun.widget.getHorizontalDimensionBehaviour();
|
|
|
|
if (horizontalDimensionBehaviour == ConstraintWidget.DimensionBehaviour.FIXED || horizontalDimensionBehaviour == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT) {
|
|
|
|
if (!dependencyNode.targets.isEmpty() && dependencyNode2.targets.isEmpty()) {
|
|
|
|
StringBuilder L2 = a.L("\n");
|
|
|
|
L2.append(dependencyNode2.name());
|
|
|
|
L2.append(" -> ");
|
|
|
|
L2.append(dependencyNode.name());
|
|
|
|
L2.append("\n");
|
2021-07-13 20:23:20 +00:00
|
|
|
generateDisplayNode = a.t(generateDisplayNode, L2.toString());
|
2021-06-27 20:44:35 +00:00
|
|
|
} else if (dependencyNode.targets.isEmpty() && !dependencyNode2.targets.isEmpty()) {
|
|
|
|
StringBuilder L3 = a.L("\n");
|
|
|
|
L3.append(dependencyNode.name());
|
|
|
|
L3.append(" -> ");
|
|
|
|
L3.append(dependencyNode2.name());
|
|
|
|
L3.append("\n");
|
2021-07-13 20:23:20 +00:00
|
|
|
generateDisplayNode = a.t(generateDisplayNode, L3.toString());
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
} else if (horizontalDimensionBehaviour == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && widgetRun.widget.getDimensionRatio() > 0.0f) {
|
|
|
|
widgetRun.widget.getDebugName();
|
|
|
|
}
|
|
|
|
} else if (z3 || (z2 && ((ChainRun) widgetRun).orientation == 1)) {
|
|
|
|
ConstraintWidget.DimensionBehaviour verticalDimensionBehaviour = widgetRun.widget.getVerticalDimensionBehaviour();
|
|
|
|
if (verticalDimensionBehaviour == ConstraintWidget.DimensionBehaviour.FIXED || verticalDimensionBehaviour == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT) {
|
|
|
|
if (!dependencyNode.targets.isEmpty() && dependencyNode2.targets.isEmpty()) {
|
|
|
|
StringBuilder L4 = a.L("\n");
|
|
|
|
L4.append(dependencyNode2.name());
|
|
|
|
L4.append(" -> ");
|
|
|
|
L4.append(dependencyNode.name());
|
|
|
|
L4.append("\n");
|
2021-07-13 20:23:20 +00:00
|
|
|
generateDisplayNode = a.t(generateDisplayNode, L4.toString());
|
2021-06-27 20:44:35 +00:00
|
|
|
} else if (dependencyNode.targets.isEmpty() && !dependencyNode2.targets.isEmpty()) {
|
|
|
|
StringBuilder L5 = a.L("\n");
|
|
|
|
L5.append(dependencyNode.name());
|
|
|
|
L5.append(" -> ");
|
|
|
|
L5.append(dependencyNode2.name());
|
|
|
|
L5.append("\n");
|
2021-07-13 20:23:20 +00:00
|
|
|
generateDisplayNode = a.t(generateDisplayNode, L5.toString());
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
} else if (verticalDimensionBehaviour == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && widgetRun.widget.getDimensionRatio() > 0.0f) {
|
|
|
|
widgetRun.widget.getDebugName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return widgetRun instanceof ChainRun ? generateChainDisplayGraph((ChainRun) widgetRun, generateDisplayNode) : generateDisplayNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
private String generateDisplayNode(DependencyNode dependencyNode, boolean z2, String str) {
|
|
|
|
for (DependencyNode dependencyNode2 : dependencyNode.targets) {
|
|
|
|
StringBuilder L = a.L("\n");
|
|
|
|
L.append(dependencyNode.name());
|
|
|
|
StringBuilder P = a.P(L.toString(), " -> ");
|
|
|
|
P.append(dependencyNode2.name());
|
|
|
|
String sb = P.toString();
|
|
|
|
if (dependencyNode.margin > 0 || z2 || (dependencyNode.run instanceof HelperReferences)) {
|
2021-07-13 20:23:20 +00:00
|
|
|
String t = a.t(sb, "[");
|
2021-06-27 20:44:35 +00:00
|
|
|
if (dependencyNode.margin > 0) {
|
2021-07-13 20:23:20 +00:00
|
|
|
t = a.y(a.P(t, "label=\""), dependencyNode.margin, "\"");
|
2021-06-27 20:44:35 +00:00
|
|
|
if (z2) {
|
2021-07-13 20:23:20 +00:00
|
|
|
t = a.t(t, ",");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (z2) {
|
2021-07-13 20:23:20 +00:00
|
|
|
t = a.t(t, " style=dashed ");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
if (dependencyNode.run instanceof HelperReferences) {
|
2021-07-13 20:23:20 +00:00
|
|
|
t = a.t(t, " style=bold,color=gray ");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-07-13 20:23:20 +00:00
|
|
|
sb = a.t(t, "]");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-07-13 20:23:20 +00:00
|
|
|
str = a.t(str, a.t(sb, "\n"));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean isCenteredConnection(DependencyNode dependencyNode, DependencyNode dependencyNode2) {
|
|
|
|
int i = 0;
|
|
|
|
for (DependencyNode dependencyNode3 : dependencyNode.targets) {
|
|
|
|
if (dependencyNode3 != dependencyNode2) {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int i2 = 0;
|
|
|
|
for (DependencyNode dependencyNode4 : dependencyNode2.targets) {
|
|
|
|
if (dependencyNode4 != dependencyNode) {
|
|
|
|
i2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return i > 0 && i2 > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void measure(ConstraintWidget constraintWidget, ConstraintWidget.DimensionBehaviour dimensionBehaviour, int i, ConstraintWidget.DimensionBehaviour dimensionBehaviour2, int i2) {
|
|
|
|
BasicMeasure.Measure measure = this.mMeasure;
|
|
|
|
measure.horizontalBehavior = dimensionBehaviour;
|
|
|
|
measure.verticalBehavior = dimensionBehaviour2;
|
|
|
|
measure.horizontalDimension = i;
|
|
|
|
measure.verticalDimension = i2;
|
|
|
|
this.mMeasurer.measure(constraintWidget, measure);
|
|
|
|
constraintWidget.setWidth(this.mMeasure.measuredWidth);
|
|
|
|
constraintWidget.setHeight(this.mMeasure.measuredHeight);
|
|
|
|
constraintWidget.setHasBaseline(this.mMeasure.measuredHasBaseline);
|
|
|
|
constraintWidget.setBaselineDistance(this.mMeasure.measuredBaseline);
|
|
|
|
}
|
|
|
|
|
|
|
|
private String nodeDefinition(WidgetRun widgetRun) {
|
|
|
|
String str;
|
|
|
|
String str2;
|
|
|
|
String str3;
|
|
|
|
boolean z2 = widgetRun instanceof VerticalWidgetRun;
|
|
|
|
String debugName = widgetRun.widget.getDebugName();
|
|
|
|
ConstraintWidget constraintWidget = widgetRun.widget;
|
|
|
|
ConstraintWidget.DimensionBehaviour horizontalDimensionBehaviour = !z2 ? constraintWidget.getHorizontalDimensionBehaviour() : constraintWidget.getVerticalDimensionBehaviour();
|
|
|
|
RunGroup runGroup = widgetRun.runGroup;
|
2021-07-13 20:23:20 +00:00
|
|
|
String t = a.t(a.t(a.t(!z2 ? a.t(debugName, "_HORIZONTAL") : a.t(debugName, "_VERTICAL"), " [shape=none, label=<"), "<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"2\">"), " <TR>");
|
2021-06-27 20:44:35 +00:00
|
|
|
if (!z2) {
|
2021-07-13 20:23:20 +00:00
|
|
|
String t2 = a.t(t, " <TD ");
|
2021-06-27 20:44:35 +00:00
|
|
|
if (widgetRun.start.resolved) {
|
2021-07-13 20:23:20 +00:00
|
|
|
t2 = a.t(t2, " BGCOLOR=\"green\"");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-07-13 20:23:20 +00:00
|
|
|
str = a.t(t2, " PORT=\"LEFT\" BORDER=\"1\">L</TD>");
|
2021-06-27 20:44:35 +00:00
|
|
|
} else {
|
2021-07-13 20:23:20 +00:00
|
|
|
String t3 = a.t(t, " <TD ");
|
2021-06-27 20:44:35 +00:00
|
|
|
if (widgetRun.start.resolved) {
|
2021-07-13 20:23:20 +00:00
|
|
|
t3 = a.t(t3, " BGCOLOR=\"green\"");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-07-13 20:23:20 +00:00
|
|
|
str = a.t(t3, " PORT=\"TOP\" BORDER=\"1\">T</TD>");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-07-13 20:23:20 +00:00
|
|
|
String t4 = a.t(str, " <TD BORDER=\"1\" ");
|
2021-06-27 20:44:35 +00:00
|
|
|
boolean z3 = widgetRun.dimension.resolved;
|
|
|
|
if (z3 && !widgetRun.widget.measured) {
|
2021-07-13 20:23:20 +00:00
|
|
|
t4 = a.t(t4, " BGCOLOR=\"green\" ");
|
2021-06-27 20:44:35 +00:00
|
|
|
} else if (z3 && widgetRun.widget.measured) {
|
2021-07-13 20:23:20 +00:00
|
|
|
t4 = a.t(t4, " BGCOLOR=\"lightgray\" ");
|
2021-06-27 20:44:35 +00:00
|
|
|
} else if (!z3 && widgetRun.widget.measured) {
|
2021-07-13 20:23:20 +00:00
|
|
|
t4 = a.t(t4, " BGCOLOR=\"yellow\" ");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
if (horizontalDimensionBehaviour == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT) {
|
2021-07-13 20:23:20 +00:00
|
|
|
t4 = a.t(t4, "style=\"dashed\"");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
if (runGroup != null) {
|
|
|
|
StringBuilder L = a.L(" [");
|
|
|
|
L.append(runGroup.groupIndex + 1);
|
|
|
|
L.append("/");
|
2021-07-13 20:23:20 +00:00
|
|
|
str2 = a.y(L, RunGroup.index, "]");
|
2021-06-27 20:44:35 +00:00
|
|
|
} else {
|
|
|
|
str2 = "";
|
|
|
|
}
|
2021-07-13 20:23:20 +00:00
|
|
|
String str4 = t4 + ">" + debugName + str2 + " </TD>";
|
2021-06-27 20:44:35 +00:00
|
|
|
if (!z2) {
|
2021-07-13 20:23:20 +00:00
|
|
|
String t5 = a.t(str4, " <TD ");
|
2021-06-27 20:44:35 +00:00
|
|
|
if (widgetRun.end.resolved) {
|
2021-07-13 20:23:20 +00:00
|
|
|
t5 = a.t(t5, " BGCOLOR=\"green\"");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-07-13 20:23:20 +00:00
|
|
|
str3 = a.t(t5, " PORT=\"RIGHT\" BORDER=\"1\">R</TD>");
|
2021-06-27 20:44:35 +00:00
|
|
|
} else {
|
2021-07-13 20:23:20 +00:00
|
|
|
String t6 = a.t(str4, " <TD ");
|
2021-06-27 20:44:35 +00:00
|
|
|
if ((widgetRun instanceof VerticalWidgetRun) && ((VerticalWidgetRun) widgetRun).baseline.resolved) {
|
2021-07-13 20:23:20 +00:00
|
|
|
t6 = a.t(t6, " BGCOLOR=\"green\"");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-07-13 20:23:20 +00:00
|
|
|
String t7 = a.t(a.t(t6, " PORT=\"BASELINE\" BORDER=\"1\">b</TD>"), " <TD ");
|
2021-06-27 20:44:35 +00:00
|
|
|
if (widgetRun.end.resolved) {
|
2021-07-13 20:23:20 +00:00
|
|
|
t7 = a.t(t7, " BGCOLOR=\"green\"");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-07-13 20:23:20 +00:00
|
|
|
str3 = a.t(t7, " PORT=\"BOTTOM\" BORDER=\"1\">B</TD>");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-07-13 20:23:20 +00:00
|
|
|
return a.t(a.t(str3, " </TR></TABLE>"), ">];\n");
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void buildGraph() {
|
|
|
|
buildGraph(this.mRuns);
|
|
|
|
this.mGroups.clear();
|
|
|
|
RunGroup.index = 0;
|
|
|
|
findGroup(this.container.horizontalRun, 0, this.mGroups);
|
|
|
|
findGroup(this.container.verticalRun, 1, this.mGroups);
|
|
|
|
this.mNeedBuildGraph = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void buildGraph(ArrayList<WidgetRun> arrayList) {
|
|
|
|
arrayList.clear();
|
|
|
|
this.mContainer.horizontalRun.clear();
|
|
|
|
this.mContainer.verticalRun.clear();
|
|
|
|
arrayList.add(this.mContainer.horizontalRun);
|
|
|
|
arrayList.add(this.mContainer.verticalRun);
|
|
|
|
Iterator<ConstraintWidget> it = this.mContainer.mChildren.iterator();
|
|
|
|
HashSet hashSet = null;
|
|
|
|
while (it.hasNext()) {
|
|
|
|
ConstraintWidget next = it.next();
|
|
|
|
if (next instanceof Guideline) {
|
|
|
|
arrayList.add(new GuidelineReference(next));
|
|
|
|
} else {
|
|
|
|
if (next.isInHorizontalChain()) {
|
|
|
|
if (next.horizontalChainRun == null) {
|
|
|
|
next.horizontalChainRun = new ChainRun(next, 0);
|
|
|
|
}
|
|
|
|
if (hashSet == null) {
|
|
|
|
hashSet = new HashSet();
|
|
|
|
}
|
|
|
|
hashSet.add(next.horizontalChainRun);
|
|
|
|
} else {
|
|
|
|
arrayList.add(next.horizontalRun);
|
|
|
|
}
|
|
|
|
if (next.isInVerticalChain()) {
|
|
|
|
if (next.verticalChainRun == null) {
|
|
|
|
next.verticalChainRun = new ChainRun(next, 1);
|
|
|
|
}
|
|
|
|
if (hashSet == null) {
|
|
|
|
hashSet = new HashSet();
|
|
|
|
}
|
|
|
|
hashSet.add(next.verticalChainRun);
|
|
|
|
} else {
|
|
|
|
arrayList.add(next.verticalRun);
|
|
|
|
}
|
|
|
|
if (next instanceof HelperWidget) {
|
|
|
|
arrayList.add(new HelperReferences(next));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hashSet != null) {
|
|
|
|
arrayList.addAll(hashSet);
|
|
|
|
}
|
|
|
|
Iterator<WidgetRun> it2 = arrayList.iterator();
|
|
|
|
while (it2.hasNext()) {
|
|
|
|
it2.next().clear();
|
|
|
|
}
|
|
|
|
Iterator<WidgetRun> it3 = arrayList.iterator();
|
|
|
|
while (it3.hasNext()) {
|
|
|
|
WidgetRun next2 = it3.next();
|
|
|
|
if (next2.widget != this.mContainer) {
|
|
|
|
next2.apply();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void defineTerminalWidgets(ConstraintWidget.DimensionBehaviour dimensionBehaviour, ConstraintWidget.DimensionBehaviour dimensionBehaviour2) {
|
|
|
|
if (this.mNeedBuildGraph) {
|
|
|
|
buildGraph();
|
|
|
|
Iterator<ConstraintWidget> it = this.container.mChildren.iterator();
|
|
|
|
boolean z2 = false;
|
|
|
|
while (it.hasNext()) {
|
|
|
|
ConstraintWidget next = it.next();
|
|
|
|
boolean[] zArr = next.isTerminalWidget;
|
|
|
|
zArr[0] = true;
|
|
|
|
zArr[1] = true;
|
|
|
|
if (next instanceof Barrier) {
|
|
|
|
z2 = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!z2) {
|
|
|
|
Iterator<RunGroup> it2 = this.mGroups.iterator();
|
|
|
|
while (it2.hasNext()) {
|
|
|
|
RunGroup next2 = it2.next();
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour3 = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
|
|
|
next2.defineTerminalWidgets(dimensionBehaviour == dimensionBehaviour3, dimensionBehaviour2 == dimensionBehaviour3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:61:0x018e, code lost:
|
|
|
|
r0 = false;
|
|
|
|
*/
|
|
|
|
public boolean directMeasure(boolean z2) {
|
|
|
|
boolean z3;
|
|
|
|
boolean z4 = true;
|
|
|
|
boolean z5 = z2 & true;
|
|
|
|
if (this.mNeedBuildGraph || this.mNeedRedoMeasures) {
|
|
|
|
Iterator<ConstraintWidget> it = this.container.mChildren.iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
ConstraintWidget next = it.next();
|
|
|
|
next.ensureWidgetRuns();
|
|
|
|
next.measured = false;
|
|
|
|
next.horizontalRun.reset();
|
|
|
|
next.verticalRun.reset();
|
|
|
|
}
|
|
|
|
this.container.ensureWidgetRuns();
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer = this.container;
|
|
|
|
constraintWidgetContainer.measured = false;
|
|
|
|
constraintWidgetContainer.horizontalRun.reset();
|
|
|
|
this.container.verticalRun.reset();
|
|
|
|
this.mNeedRedoMeasures = false;
|
|
|
|
}
|
|
|
|
if (basicMeasureWidgets(this.mContainer)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
this.container.setX(0);
|
|
|
|
this.container.setY(0);
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour = this.container.getDimensionBehaviour(0);
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour2 = this.container.getDimensionBehaviour(1);
|
|
|
|
if (this.mNeedBuildGraph) {
|
|
|
|
buildGraph();
|
|
|
|
}
|
|
|
|
int x2 = this.container.getX();
|
|
|
|
int y2 = this.container.getY();
|
|
|
|
this.container.horizontalRun.start.resolve(x2);
|
|
|
|
this.container.verticalRun.start.resolve(y2);
|
|
|
|
measureWidgets();
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour3 = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
|
|
|
if (dimensionBehaviour == dimensionBehaviour3 || dimensionBehaviour2 == dimensionBehaviour3) {
|
|
|
|
if (z5) {
|
|
|
|
Iterator<WidgetRun> it2 = this.mRuns.iterator();
|
|
|
|
while (true) {
|
|
|
|
if (it2.hasNext()) {
|
|
|
|
if (!it2.next().supportsWrapComputation()) {
|
|
|
|
z5 = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (z5 && dimensionBehaviour == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT) {
|
|
|
|
this.container.setHorizontalDimensionBehaviour(ConstraintWidget.DimensionBehaviour.FIXED);
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer2 = this.container;
|
|
|
|
constraintWidgetContainer2.setWidth(computeWrap(constraintWidgetContainer2, 0));
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer3 = this.container;
|
|
|
|
constraintWidgetContainer3.horizontalRun.dimension.resolve(constraintWidgetContainer3.getWidth());
|
|
|
|
}
|
|
|
|
if (z5 && dimensionBehaviour2 == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT) {
|
|
|
|
this.container.setVerticalDimensionBehaviour(ConstraintWidget.DimensionBehaviour.FIXED);
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer4 = this.container;
|
|
|
|
constraintWidgetContainer4.setHeight(computeWrap(constraintWidgetContainer4, 1));
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer5 = this.container;
|
|
|
|
constraintWidgetContainer5.verticalRun.dimension.resolve(constraintWidgetContainer5.getHeight());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer6 = this.container;
|
|
|
|
ConstraintWidget.DimensionBehaviour[] dimensionBehaviourArr = constraintWidgetContainer6.mListDimensionBehaviors;
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour4 = dimensionBehaviourArr[0];
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour5 = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
|
|
if (dimensionBehaviour4 == dimensionBehaviour5 || dimensionBehaviourArr[0] == ConstraintWidget.DimensionBehaviour.MATCH_PARENT) {
|
|
|
|
int width = constraintWidgetContainer6.getWidth() + x2;
|
|
|
|
this.container.horizontalRun.end.resolve(width);
|
|
|
|
this.container.horizontalRun.dimension.resolve(width - x2);
|
|
|
|
measureWidgets();
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer7 = this.container;
|
|
|
|
ConstraintWidget.DimensionBehaviour[] dimensionBehaviourArr2 = constraintWidgetContainer7.mListDimensionBehaviors;
|
|
|
|
if (dimensionBehaviourArr2[1] == dimensionBehaviour5 || dimensionBehaviourArr2[1] == ConstraintWidget.DimensionBehaviour.MATCH_PARENT) {
|
|
|
|
int height = constraintWidgetContainer7.getHeight() + y2;
|
|
|
|
this.container.verticalRun.end.resolve(height);
|
|
|
|
this.container.verticalRun.dimension.resolve(height - y2);
|
|
|
|
}
|
|
|
|
measureWidgets();
|
|
|
|
z3 = true;
|
|
|
|
} else {
|
|
|
|
z3 = false;
|
|
|
|
}
|
|
|
|
Iterator<WidgetRun> it3 = this.mRuns.iterator();
|
|
|
|
while (it3.hasNext()) {
|
|
|
|
WidgetRun next2 = it3.next();
|
|
|
|
if (next2.widget != this.container || next2.resolved) {
|
|
|
|
next2.applyToWidget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Iterator<WidgetRun> it4 = this.mRuns.iterator();
|
|
|
|
while (true) {
|
|
|
|
if (!it4.hasNext()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
WidgetRun next3 = it4.next();
|
|
|
|
if (z3 || next3.widget != this.container) {
|
|
|
|
if (!next3.start.resolved || ((!next3.end.resolved && !(next3 instanceof GuidelineReference)) || (!next3.dimension.resolved && !(next3 instanceof ChainRun) && !(next3 instanceof GuidelineReference)))) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.container.setHorizontalDimensionBehaviour(dimensionBehaviour);
|
|
|
|
this.container.setVerticalDimensionBehaviour(dimensionBehaviour2);
|
|
|
|
return z4;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean directMeasureSetup(boolean z2) {
|
|
|
|
if (this.mNeedBuildGraph) {
|
|
|
|
Iterator<ConstraintWidget> it = this.container.mChildren.iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
ConstraintWidget next = it.next();
|
|
|
|
next.ensureWidgetRuns();
|
|
|
|
next.measured = false;
|
|
|
|
HorizontalWidgetRun horizontalWidgetRun = next.horizontalRun;
|
|
|
|
horizontalWidgetRun.dimension.resolved = false;
|
|
|
|
horizontalWidgetRun.resolved = false;
|
|
|
|
horizontalWidgetRun.reset();
|
|
|
|
VerticalWidgetRun verticalWidgetRun = next.verticalRun;
|
|
|
|
verticalWidgetRun.dimension.resolved = false;
|
|
|
|
verticalWidgetRun.resolved = false;
|
|
|
|
verticalWidgetRun.reset();
|
|
|
|
}
|
|
|
|
this.container.ensureWidgetRuns();
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer = this.container;
|
|
|
|
constraintWidgetContainer.measured = false;
|
|
|
|
HorizontalWidgetRun horizontalWidgetRun2 = constraintWidgetContainer.horizontalRun;
|
|
|
|
horizontalWidgetRun2.dimension.resolved = false;
|
|
|
|
horizontalWidgetRun2.resolved = false;
|
|
|
|
horizontalWidgetRun2.reset();
|
|
|
|
VerticalWidgetRun verticalWidgetRun2 = this.container.verticalRun;
|
|
|
|
verticalWidgetRun2.dimension.resolved = false;
|
|
|
|
verticalWidgetRun2.resolved = false;
|
|
|
|
verticalWidgetRun2.reset();
|
|
|
|
buildGraph();
|
|
|
|
}
|
|
|
|
if (basicMeasureWidgets(this.mContainer)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
this.container.setX(0);
|
|
|
|
this.container.setY(0);
|
|
|
|
this.container.horizontalRun.start.resolve(0);
|
|
|
|
this.container.verticalRun.start.resolve(0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:38:0x00ef */
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:48:0x0115 */
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:78:0x0143 A[EDGE_INSN: B:78:0x0143->B:62:0x0143 ?: BREAK , SYNTHETIC] */
|
|
|
|
public boolean directMeasureWithOrientation(boolean z2, int i) {
|
|
|
|
boolean z3;
|
|
|
|
Iterator<WidgetRun> it;
|
|
|
|
Iterator<WidgetRun> it2;
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour;
|
|
|
|
boolean z4 = true;
|
|
|
|
boolean z5 = z2 & true;
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour2 = this.container.getDimensionBehaviour(0);
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour3 = this.container.getDimensionBehaviour(1);
|
|
|
|
int x2 = this.container.getX();
|
|
|
|
int y2 = this.container.getY();
|
|
|
|
if (z5 && (dimensionBehaviour2 == (dimensionBehaviour = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT) || dimensionBehaviour3 == dimensionBehaviour)) {
|
|
|
|
Iterator<WidgetRun> it3 = this.mRuns.iterator();
|
|
|
|
while (true) {
|
|
|
|
if (!it3.hasNext()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
WidgetRun next = it3.next();
|
|
|
|
if (next.orientation == i && !next.supportsWrapComputation()) {
|
|
|
|
z5 = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == 0) {
|
|
|
|
if (z5 && dimensionBehaviour2 == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT) {
|
|
|
|
this.container.setHorizontalDimensionBehaviour(ConstraintWidget.DimensionBehaviour.FIXED);
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer = this.container;
|
|
|
|
constraintWidgetContainer.setWidth(computeWrap(constraintWidgetContainer, 0));
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer2 = this.container;
|
|
|
|
constraintWidgetContainer2.horizontalRun.dimension.resolve(constraintWidgetContainer2.getWidth());
|
|
|
|
}
|
|
|
|
} else if (z5 && dimensionBehaviour3 == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT) {
|
|
|
|
this.container.setVerticalDimensionBehaviour(ConstraintWidget.DimensionBehaviour.FIXED);
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer3 = this.container;
|
|
|
|
constraintWidgetContainer3.setHeight(computeWrap(constraintWidgetContainer3, 1));
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer4 = this.container;
|
|
|
|
constraintWidgetContainer4.verticalRun.dimension.resolve(constraintWidgetContainer4.getHeight());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == 0) {
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer5 = this.container;
|
|
|
|
ConstraintWidget.DimensionBehaviour[] dimensionBehaviourArr = constraintWidgetContainer5.mListDimensionBehaviors;
|
|
|
|
if (dimensionBehaviourArr[0] == ConstraintWidget.DimensionBehaviour.FIXED || dimensionBehaviourArr[0] == ConstraintWidget.DimensionBehaviour.MATCH_PARENT) {
|
|
|
|
int width = constraintWidgetContainer5.getWidth() + x2;
|
|
|
|
this.container.horizontalRun.end.resolve(width);
|
|
|
|
this.container.horizontalRun.dimension.resolve(width - x2);
|
|
|
|
z3 = true;
|
|
|
|
measureWidgets();
|
|
|
|
it = this.mRuns.iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
WidgetRun next2 = it.next();
|
|
|
|
if (next2.orientation == i && (next2.widget != this.container || next2.resolved)) {
|
|
|
|
next2.applyToWidget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
it2 = this.mRuns.iterator();
|
|
|
|
while (true) {
|
|
|
|
if (!it2.hasNext()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
WidgetRun next3 = it2.next();
|
|
|
|
if (next3.orientation == i && (z3 || next3.widget != this.container)) {
|
|
|
|
if (!next3.start.resolved || !next3.end.resolved || (!(next3 instanceof ChainRun) && !next3.dimension.resolved)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
z4 = false;
|
|
|
|
this.container.setHorizontalDimensionBehaviour(dimensionBehaviour2);
|
|
|
|
this.container.setVerticalDimensionBehaviour(dimensionBehaviour3);
|
|
|
|
return z4;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ConstraintWidgetContainer constraintWidgetContainer6 = this.container;
|
|
|
|
ConstraintWidget.DimensionBehaviour[] dimensionBehaviourArr2 = constraintWidgetContainer6.mListDimensionBehaviors;
|
|
|
|
if (dimensionBehaviourArr2[1] == ConstraintWidget.DimensionBehaviour.FIXED || dimensionBehaviourArr2[1] == ConstraintWidget.DimensionBehaviour.MATCH_PARENT) {
|
|
|
|
int height = constraintWidgetContainer6.getHeight() + y2;
|
|
|
|
this.container.verticalRun.end.resolve(height);
|
|
|
|
this.container.verticalRun.dimension.resolve(height - y2);
|
|
|
|
z3 = true;
|
|
|
|
measureWidgets();
|
|
|
|
it = this.mRuns.iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
}
|
|
|
|
it2 = this.mRuns.iterator();
|
|
|
|
while (true) {
|
|
|
|
if (!it2.hasNext()) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
z4 = false;
|
|
|
|
this.container.setHorizontalDimensionBehaviour(dimensionBehaviour2);
|
|
|
|
this.container.setVerticalDimensionBehaviour(dimensionBehaviour3);
|
|
|
|
return z4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
z3 = false;
|
|
|
|
measureWidgets();
|
|
|
|
it = this.mRuns.iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
}
|
|
|
|
it2 = this.mRuns.iterator();
|
|
|
|
while (true) {
|
|
|
|
if (!it2.hasNext()) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
z4 = false;
|
|
|
|
this.container.setHorizontalDimensionBehaviour(dimensionBehaviour2);
|
|
|
|
this.container.setVerticalDimensionBehaviour(dimensionBehaviour3);
|
|
|
|
return z4;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void invalidateGraph() {
|
|
|
|
this.mNeedBuildGraph = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void invalidateMeasures() {
|
|
|
|
this.mNeedRedoMeasures = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void measureWidgets() {
|
|
|
|
DimensionDependency dimensionDependency;
|
|
|
|
Iterator<ConstraintWidget> it = this.container.mChildren.iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
ConstraintWidget next = it.next();
|
|
|
|
if (!next.measured) {
|
|
|
|
ConstraintWidget.DimensionBehaviour[] dimensionBehaviourArr = next.mListDimensionBehaviors;
|
|
|
|
boolean z2 = false;
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour = dimensionBehaviourArr[0];
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour2 = dimensionBehaviourArr[1];
|
|
|
|
int i = next.mMatchConstraintDefaultWidth;
|
|
|
|
int i2 = next.mMatchConstraintDefaultHeight;
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour3 = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
|
|
|
boolean z3 = dimensionBehaviour == dimensionBehaviour3 || (dimensionBehaviour == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && i == 1);
|
|
|
|
if (dimensionBehaviour2 == dimensionBehaviour3 || (dimensionBehaviour2 == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT && i2 == 1)) {
|
|
|
|
z2 = true;
|
|
|
|
}
|
|
|
|
DimensionDependency dimensionDependency2 = next.horizontalRun.dimension;
|
|
|
|
boolean z4 = dimensionDependency2.resolved;
|
|
|
|
DimensionDependency dimensionDependency3 = next.verticalRun.dimension;
|
|
|
|
boolean z5 = dimensionDependency3.resolved;
|
|
|
|
if (z4 && z5) {
|
|
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour4 = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
|
|
measure(next, dimensionBehaviour4, dimensionDependency2.value, dimensionBehaviour4, dimensionDependency3.value);
|
|
|
|
next.measured = true;
|
|
|
|
} else if (z4 && z2) {
|
|
|
|
measure(next, ConstraintWidget.DimensionBehaviour.FIXED, dimensionDependency2.value, dimensionBehaviour3, dimensionDependency3.value);
|
|
|
|
if (dimensionBehaviour2 == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT) {
|
|
|
|
next.verticalRun.dimension.wrapValue = next.getHeight();
|
|
|
|
} else {
|
|
|
|
next.verticalRun.dimension.resolve(next.getHeight());
|
|
|
|
next.measured = true;
|
|
|
|
}
|
|
|
|
} else if (z5 && z3) {
|
|
|
|
measure(next, dimensionBehaviour3, dimensionDependency2.value, ConstraintWidget.DimensionBehaviour.FIXED, dimensionDependency3.value);
|
|
|
|
if (dimensionBehaviour == ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT) {
|
|
|
|
next.horizontalRun.dimension.wrapValue = next.getWidth();
|
|
|
|
} else {
|
|
|
|
next.horizontalRun.dimension.resolve(next.getWidth());
|
|
|
|
next.measured = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (next.measured && (dimensionDependency = next.verticalRun.baselineDimension) != null) {
|
|
|
|
dimensionDependency.resolve(next.getBaselineDistance());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMeasurer(BasicMeasure.Measurer measurer) {
|
|
|
|
this.mMeasurer = measurer;
|
|
|
|
}
|
|
|
|
}
|