2021-07-24 02:37:17 +00:00
|
|
|
package androidx.constraintlayout.solver.widgets.analyzer;
|
|
|
|
|
|
|
|
import androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer;
|
2021-12-17 21:59:34 +00:00
|
|
|
import b.d.b.a.a;
|
2021-07-24 02:37:17 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Iterator;
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public class RunGroup {
|
|
|
|
public static final int BASELINE = 2;
|
|
|
|
public static final int END = 1;
|
|
|
|
public static final int START = 0;
|
|
|
|
public static int index;
|
|
|
|
public int direction;
|
2022-03-07 09:34:54 +00:00
|
|
|
public WidgetRun firstRun;
|
|
|
|
public int groupIndex;
|
|
|
|
public WidgetRun lastRun;
|
2021-07-24 02:37:17 +00:00
|
|
|
public int position = 0;
|
2022-03-07 09:34:54 +00:00
|
|
|
public boolean dual = false;
|
2021-07-24 02:37:17 +00:00
|
|
|
public ArrayList<WidgetRun> runs = new ArrayList<>();
|
|
|
|
|
|
|
|
public RunGroup(WidgetRun widgetRun, int i) {
|
2022-03-07 09:34:54 +00:00
|
|
|
this.firstRun = null;
|
|
|
|
this.lastRun = null;
|
|
|
|
this.groupIndex = 0;
|
2021-07-24 02:37:17 +00:00
|
|
|
int i2 = index;
|
|
|
|
this.groupIndex = i2;
|
|
|
|
index = i2 + 1;
|
|
|
|
this.firstRun = widgetRun;
|
|
|
|
this.lastRun = widgetRun;
|
|
|
|
this.direction = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean defineTerminalWidget(WidgetRun widgetRun, int i) {
|
|
|
|
DependencyNode dependencyNode;
|
|
|
|
WidgetRun widgetRun2;
|
|
|
|
DependencyNode dependencyNode2;
|
|
|
|
WidgetRun widgetRun3;
|
|
|
|
if (!widgetRun.widget.isTerminalWidget[i]) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (Dependency dependency : widgetRun.start.dependencies) {
|
|
|
|
if ((dependency instanceof DependencyNode) && (widgetRun3 = (dependencyNode2 = (DependencyNode) dependency).run) != widgetRun && dependencyNode2 == widgetRun3.start) {
|
|
|
|
if (widgetRun instanceof ChainRun) {
|
|
|
|
Iterator<WidgetRun> it = ((ChainRun) widgetRun).widgets.iterator();
|
|
|
|
while (it.hasNext()) {
|
|
|
|
defineTerminalWidget(it.next(), i);
|
|
|
|
}
|
|
|
|
} else if (!(widgetRun instanceof HelperReferences)) {
|
|
|
|
widgetRun.widget.isTerminalWidget[i] = false;
|
|
|
|
}
|
|
|
|
defineTerminalWidget(dependencyNode2.run, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (Dependency dependency2 : widgetRun.end.dependencies) {
|
|
|
|
if ((dependency2 instanceof DependencyNode) && (widgetRun2 = (dependencyNode = (DependencyNode) dependency2).run) != widgetRun && dependencyNode == widgetRun2.start) {
|
|
|
|
if (widgetRun instanceof ChainRun) {
|
|
|
|
Iterator<WidgetRun> it2 = ((ChainRun) widgetRun).widgets.iterator();
|
|
|
|
while (it2.hasNext()) {
|
|
|
|
defineTerminalWidget(it2.next(), i);
|
|
|
|
}
|
|
|
|
} else if (!(widgetRun instanceof HelperReferences)) {
|
|
|
|
widgetRun.widget.isTerminalWidget[i] = false;
|
|
|
|
}
|
|
|
|
defineTerminalWidget(dependencyNode.run, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private long traverseEnd(DependencyNode dependencyNode, long j) {
|
|
|
|
WidgetRun widgetRun = dependencyNode.run;
|
|
|
|
if (widgetRun instanceof HelperReferences) {
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
int size = dependencyNode.dependencies.size();
|
|
|
|
long j2 = j;
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
Dependency dependency = dependencyNode.dependencies.get(i);
|
|
|
|
if (dependency instanceof DependencyNode) {
|
|
|
|
DependencyNode dependencyNode2 = (DependencyNode) dependency;
|
|
|
|
if (dependencyNode2.run != widgetRun) {
|
2022-03-07 09:34:54 +00:00
|
|
|
j2 = Math.min(j2, traverseEnd(dependencyNode2, dependencyNode2.margin + j));
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dependencyNode != widgetRun.end) {
|
|
|
|
return j2;
|
|
|
|
}
|
|
|
|
long wrapDimension = j - widgetRun.getWrapDimension();
|
2022-03-07 09:34:54 +00:00
|
|
|
return Math.min(Math.min(j2, traverseEnd(widgetRun.start, wrapDimension)), wrapDimension - widgetRun.start.margin);
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private long traverseStart(DependencyNode dependencyNode, long j) {
|
|
|
|
WidgetRun widgetRun = dependencyNode.run;
|
|
|
|
if (widgetRun instanceof HelperReferences) {
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
int size = dependencyNode.dependencies.size();
|
|
|
|
long j2 = j;
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
Dependency dependency = dependencyNode.dependencies.get(i);
|
|
|
|
if (dependency instanceof DependencyNode) {
|
|
|
|
DependencyNode dependencyNode2 = (DependencyNode) dependency;
|
|
|
|
if (dependencyNode2.run != widgetRun) {
|
2022-03-07 09:34:54 +00:00
|
|
|
j2 = Math.max(j2, traverseStart(dependencyNode2, dependencyNode2.margin + j));
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dependencyNode != widgetRun.start) {
|
|
|
|
return j2;
|
|
|
|
}
|
|
|
|
long wrapDimension = j + widgetRun.getWrapDimension();
|
2022-03-07 09:34:54 +00:00
|
|
|
return Math.max(Math.max(j2, traverseStart(widgetRun.end, wrapDimension)), wrapDimension - widgetRun.end.margin);
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void add(WidgetRun widgetRun) {
|
|
|
|
this.runs.add(widgetRun);
|
|
|
|
this.lastRun = widgetRun;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long computeWrapSize(ConstraintWidgetContainer constraintWidgetContainer, int i) {
|
2022-03-07 09:34:54 +00:00
|
|
|
WidgetRun widgetRun;
|
|
|
|
DependencyNode dependencyNode;
|
|
|
|
DependencyNode dependencyNode2;
|
|
|
|
WidgetRun widgetRun2 = this.firstRun;
|
2021-07-24 02:37:17 +00:00
|
|
|
long j = 0;
|
2022-03-07 09:34:54 +00:00
|
|
|
if (widgetRun2 instanceof ChainRun) {
|
|
|
|
if (((ChainRun) widgetRun2).orientation != i) {
|
|
|
|
return 0L;
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
} else if (i == 0) {
|
2022-03-07 09:34:54 +00:00
|
|
|
if (!(widgetRun2 instanceof HorizontalWidgetRun)) {
|
|
|
|
return 0L;
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
} else if (!(widgetRun2 instanceof VerticalWidgetRun)) {
|
|
|
|
return 0L;
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
DependencyNode dependencyNode3 = (i == 0 ? constraintWidgetContainer.horizontalRun : constraintWidgetContainer.verticalRun).start;
|
|
|
|
DependencyNode dependencyNode4 = (i == 0 ? constraintWidgetContainer.horizontalRun : constraintWidgetContainer.verticalRun).end;
|
|
|
|
boolean contains = widgetRun2.start.targets.contains(dependencyNode3);
|
|
|
|
boolean contains2 = this.firstRun.end.targets.contains(dependencyNode4);
|
2021-07-24 02:37:17 +00:00
|
|
|
long wrapDimension = this.firstRun.getWrapDimension();
|
|
|
|
if (contains && contains2) {
|
2022-03-07 09:34:54 +00:00
|
|
|
long traverseStart = traverseStart(this.firstRun.start, 0L);
|
|
|
|
long traverseEnd = traverseEnd(this.firstRun.end, 0L);
|
2021-07-24 02:37:17 +00:00
|
|
|
long j2 = traverseStart - wrapDimension;
|
2022-03-07 09:34:54 +00:00
|
|
|
WidgetRun widgetRun3 = this.firstRun;
|
|
|
|
int i2 = widgetRun3.end.margin;
|
|
|
|
if (j2 >= (-i2)) {
|
|
|
|
j2 += i2;
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
int i3 = widgetRun3.start.margin;
|
|
|
|
long j3 = ((-traverseEnd) - wrapDimension) - i3;
|
|
|
|
if (j3 >= i3) {
|
|
|
|
j3 -= i3;
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
float biasPercent = widgetRun3.widget.getBiasPercent(i);
|
2021-07-24 02:37:17 +00:00
|
|
|
if (biasPercent > 0.0f) {
|
2022-03-07 09:34:54 +00:00
|
|
|
j = (((float) j2) / (1.0f - biasPercent)) + (((float) j3) / biasPercent);
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
float f = (float) j;
|
2022-03-07 09:34:54 +00:00
|
|
|
long a = (f * biasPercent) + 0.5f + wrapDimension + a.a(1.0f, biasPercent, f, 0.5f);
|
|
|
|
WidgetRun widgetRun4 = this.firstRun;
|
|
|
|
return (widgetRun4.start.margin + a) - widgetRun4.end.margin;
|
2021-07-24 02:37:17 +00:00
|
|
|
} else if (contains) {
|
2022-03-07 09:34:54 +00:00
|
|
|
return Math.max(traverseStart(this.firstRun.start, dependencyNode2.margin), this.firstRun.start.margin + wrapDimension);
|
2021-07-24 02:37:17 +00:00
|
|
|
} else if (contains2) {
|
2022-03-07 09:34:54 +00:00
|
|
|
return Math.max(-traverseEnd(this.firstRun.end, dependencyNode.margin), (-this.firstRun.end.margin) + wrapDimension);
|
2021-07-24 02:37:17 +00:00
|
|
|
} else {
|
2022-03-07 09:34:54 +00:00
|
|
|
return (this.firstRun.getWrapDimension() + widgetRun.start.margin) - this.firstRun.end.margin;
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void defineTerminalWidgets(boolean z2, boolean z3) {
|
|
|
|
if (z2) {
|
|
|
|
WidgetRun widgetRun = this.firstRun;
|
|
|
|
if (widgetRun instanceof HorizontalWidgetRun) {
|
|
|
|
defineTerminalWidget(widgetRun, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (z3) {
|
|
|
|
WidgetRun widgetRun2 = this.firstRun;
|
|
|
|
if (widgetRun2 instanceof VerticalWidgetRun) {
|
|
|
|
defineTerminalWidget(widgetRun2, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|