769 lines
34 KiB
Java
769 lines
34 KiB
Java
package androidx.constraintlayout.solver.widgets;
|
|
|
|
import androidx.constraintlayout.solver.LinearSystem;
|
|
import androidx.constraintlayout.solver.Metrics;
|
|
import androidx.constraintlayout.solver.SolverVariable;
|
|
import androidx.constraintlayout.solver.widgets.ConstraintWidget;
|
|
import androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure;
|
|
import androidx.constraintlayout.solver.widgets.analyzer.DependencyGraph;
|
|
import androidx.constraintlayout.solver.widgets.analyzer.Direct;
|
|
import androidx.constraintlayout.solver.widgets.analyzer.Grouping;
|
|
import java.lang.ref.WeakReference;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
/* loaded from: classes.dex */
|
|
public class ConstraintWidgetContainer extends WidgetContainer {
|
|
private static final boolean DEBUG = false;
|
|
public static final boolean DEBUG_GRAPH = false;
|
|
private static final boolean DEBUG_LAYOUT = false;
|
|
private static final int MAX_ITERATIONS = 8;
|
|
public static int mycounter;
|
|
private WeakReference<ConstraintAnchor> horizontalWrapMax;
|
|
private WeakReference<ConstraintAnchor> horizontalWrapMin;
|
|
public BasicMeasure mBasicMeasureSolver;
|
|
public int mDebugSolverPassCount;
|
|
public DependencyGraph mDependencyGraph;
|
|
public boolean mGroupsWrapOptimized;
|
|
private boolean mHeightMeasuredTooSmall;
|
|
public ChainHead[] mHorizontalChainsArray;
|
|
public int mHorizontalChainsSize;
|
|
public boolean mHorizontalWrapOptimized;
|
|
private boolean mIsRtl;
|
|
public BasicMeasure.Measure mMeasure;
|
|
public BasicMeasure.Measurer mMeasurer;
|
|
public Metrics mMetrics;
|
|
private int mOptimizationLevel;
|
|
public int mPaddingBottom;
|
|
public int mPaddingLeft;
|
|
public int mPaddingRight;
|
|
public int mPaddingTop;
|
|
public boolean mSkipSolver;
|
|
public LinearSystem mSystem;
|
|
public ChainHead[] mVerticalChainsArray;
|
|
public int mVerticalChainsSize;
|
|
public boolean mVerticalWrapOptimized;
|
|
private boolean mWidthMeasuredTooSmall;
|
|
public int mWrapFixedHeight;
|
|
public int mWrapFixedWidth;
|
|
private WeakReference<ConstraintAnchor> verticalWrapMax;
|
|
private WeakReference<ConstraintAnchor> verticalWrapMin;
|
|
|
|
public ConstraintWidgetContainer() {
|
|
this.mBasicMeasureSolver = new BasicMeasure(this);
|
|
this.mDependencyGraph = new DependencyGraph(this);
|
|
this.mMeasurer = null;
|
|
this.mIsRtl = false;
|
|
this.mSystem = new LinearSystem();
|
|
this.mHorizontalChainsSize = 0;
|
|
this.mVerticalChainsSize = 0;
|
|
this.mVerticalChainsArray = new ChainHead[4];
|
|
this.mHorizontalChainsArray = new ChainHead[4];
|
|
this.mGroupsWrapOptimized = false;
|
|
this.mHorizontalWrapOptimized = false;
|
|
this.mVerticalWrapOptimized = false;
|
|
this.mWrapFixedWidth = 0;
|
|
this.mWrapFixedHeight = 0;
|
|
this.mOptimizationLevel = 257;
|
|
this.mSkipSolver = false;
|
|
this.mWidthMeasuredTooSmall = false;
|
|
this.mHeightMeasuredTooSmall = false;
|
|
this.mDebugSolverPassCount = 0;
|
|
this.verticalWrapMin = null;
|
|
this.horizontalWrapMin = null;
|
|
this.verticalWrapMax = null;
|
|
this.horizontalWrapMax = null;
|
|
this.mMeasure = new BasicMeasure.Measure();
|
|
}
|
|
|
|
public ConstraintWidgetContainer(int i, int i2) {
|
|
super(i, i2);
|
|
this.mBasicMeasureSolver = new BasicMeasure(this);
|
|
this.mDependencyGraph = new DependencyGraph(this);
|
|
this.mMeasurer = null;
|
|
this.mIsRtl = false;
|
|
this.mSystem = new LinearSystem();
|
|
this.mHorizontalChainsSize = 0;
|
|
this.mVerticalChainsSize = 0;
|
|
this.mVerticalChainsArray = new ChainHead[4];
|
|
this.mHorizontalChainsArray = new ChainHead[4];
|
|
this.mGroupsWrapOptimized = false;
|
|
this.mHorizontalWrapOptimized = false;
|
|
this.mVerticalWrapOptimized = false;
|
|
this.mWrapFixedWidth = 0;
|
|
this.mWrapFixedHeight = 0;
|
|
this.mOptimizationLevel = 257;
|
|
this.mSkipSolver = false;
|
|
this.mWidthMeasuredTooSmall = false;
|
|
this.mHeightMeasuredTooSmall = false;
|
|
this.mDebugSolverPassCount = 0;
|
|
this.verticalWrapMin = null;
|
|
this.horizontalWrapMin = null;
|
|
this.verticalWrapMax = null;
|
|
this.horizontalWrapMax = null;
|
|
this.mMeasure = new BasicMeasure.Measure();
|
|
}
|
|
|
|
public ConstraintWidgetContainer(int i, int i2, int i3, int i4) {
|
|
super(i, i2, i3, i4);
|
|
this.mBasicMeasureSolver = new BasicMeasure(this);
|
|
this.mDependencyGraph = new DependencyGraph(this);
|
|
this.mMeasurer = null;
|
|
this.mIsRtl = false;
|
|
this.mSystem = new LinearSystem();
|
|
this.mHorizontalChainsSize = 0;
|
|
this.mVerticalChainsSize = 0;
|
|
this.mVerticalChainsArray = new ChainHead[4];
|
|
this.mHorizontalChainsArray = new ChainHead[4];
|
|
this.mGroupsWrapOptimized = false;
|
|
this.mHorizontalWrapOptimized = false;
|
|
this.mVerticalWrapOptimized = false;
|
|
this.mWrapFixedWidth = 0;
|
|
this.mWrapFixedHeight = 0;
|
|
this.mOptimizationLevel = 257;
|
|
this.mSkipSolver = false;
|
|
this.mWidthMeasuredTooSmall = false;
|
|
this.mHeightMeasuredTooSmall = false;
|
|
this.mDebugSolverPassCount = 0;
|
|
this.verticalWrapMin = null;
|
|
this.horizontalWrapMin = null;
|
|
this.verticalWrapMax = null;
|
|
this.horizontalWrapMax = null;
|
|
this.mMeasure = new BasicMeasure.Measure();
|
|
}
|
|
|
|
public ConstraintWidgetContainer(String str, int i, int i2) {
|
|
super(i, i2);
|
|
this.mBasicMeasureSolver = new BasicMeasure(this);
|
|
this.mDependencyGraph = new DependencyGraph(this);
|
|
this.mMeasurer = null;
|
|
this.mIsRtl = false;
|
|
this.mSystem = new LinearSystem();
|
|
this.mHorizontalChainsSize = 0;
|
|
this.mVerticalChainsSize = 0;
|
|
this.mVerticalChainsArray = new ChainHead[4];
|
|
this.mHorizontalChainsArray = new ChainHead[4];
|
|
this.mGroupsWrapOptimized = false;
|
|
this.mHorizontalWrapOptimized = false;
|
|
this.mVerticalWrapOptimized = false;
|
|
this.mWrapFixedWidth = 0;
|
|
this.mWrapFixedHeight = 0;
|
|
this.mOptimizationLevel = 257;
|
|
this.mSkipSolver = false;
|
|
this.mWidthMeasuredTooSmall = false;
|
|
this.mHeightMeasuredTooSmall = false;
|
|
this.mDebugSolverPassCount = 0;
|
|
this.verticalWrapMin = null;
|
|
this.horizontalWrapMin = null;
|
|
this.verticalWrapMax = null;
|
|
this.horizontalWrapMax = null;
|
|
this.mMeasure = new BasicMeasure.Measure();
|
|
setDebugName(str);
|
|
}
|
|
|
|
private void addHorizontalChain(ConstraintWidget constraintWidget) {
|
|
int i = this.mHorizontalChainsSize + 1;
|
|
ChainHead[] chainHeadArr = this.mHorizontalChainsArray;
|
|
if (i >= chainHeadArr.length) {
|
|
this.mHorizontalChainsArray = (ChainHead[]) Arrays.copyOf(chainHeadArr, chainHeadArr.length * 2);
|
|
}
|
|
this.mHorizontalChainsArray[this.mHorizontalChainsSize] = new ChainHead(constraintWidget, 0, isRtl());
|
|
this.mHorizontalChainsSize++;
|
|
}
|
|
|
|
private void addMaxWrap(ConstraintAnchor constraintAnchor, SolverVariable solverVariable) {
|
|
this.mSystem.addGreaterThan(solverVariable, this.mSystem.createObjectVariable(constraintAnchor), 0, 5);
|
|
}
|
|
|
|
private void addMinWrap(ConstraintAnchor constraintAnchor, SolverVariable solverVariable) {
|
|
this.mSystem.addGreaterThan(this.mSystem.createObjectVariable(constraintAnchor), solverVariable, 0, 5);
|
|
}
|
|
|
|
private void addVerticalChain(ConstraintWidget constraintWidget) {
|
|
int i = this.mVerticalChainsSize + 1;
|
|
ChainHead[] chainHeadArr = this.mVerticalChainsArray;
|
|
if (i >= chainHeadArr.length) {
|
|
this.mVerticalChainsArray = (ChainHead[]) Arrays.copyOf(chainHeadArr, chainHeadArr.length * 2);
|
|
}
|
|
this.mVerticalChainsArray[this.mVerticalChainsSize] = new ChainHead(constraintWidget, 1, isRtl());
|
|
this.mVerticalChainsSize++;
|
|
}
|
|
|
|
public static boolean measure(ConstraintWidget constraintWidget, BasicMeasure.Measurer measurer, BasicMeasure.Measure measure, int i) {
|
|
int i2;
|
|
int i3;
|
|
if (measurer == null) {
|
|
return false;
|
|
}
|
|
measure.horizontalBehavior = constraintWidget.getHorizontalDimensionBehaviour();
|
|
measure.verticalBehavior = constraintWidget.getVerticalDimensionBehaviour();
|
|
measure.horizontalDimension = constraintWidget.getWidth();
|
|
measure.verticalDimension = constraintWidget.getHeight();
|
|
measure.measuredNeedsSolverPass = false;
|
|
measure.measureStrategy = i;
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour = measure.horizontalBehavior;
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour2 = ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT;
|
|
boolean z2 = dimensionBehaviour == dimensionBehaviour2;
|
|
boolean z3 = measure.verticalBehavior == dimensionBehaviour2;
|
|
boolean z4 = z2 && constraintWidget.mDimensionRatio > 0.0f;
|
|
boolean z5 = z3 && constraintWidget.mDimensionRatio > 0.0f;
|
|
if (z2 && constraintWidget.hasDanglingDimension(0) && constraintWidget.mMatchConstraintDefaultWidth == 0 && !z4) {
|
|
measure.horizontalBehavior = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
|
if (z3 && constraintWidget.mMatchConstraintDefaultHeight == 0) {
|
|
measure.horizontalBehavior = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
}
|
|
z2 = false;
|
|
}
|
|
if (z3 && constraintWidget.hasDanglingDimension(1) && constraintWidget.mMatchConstraintDefaultHeight == 0 && !z5) {
|
|
measure.verticalBehavior = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
|
if (z2 && constraintWidget.mMatchConstraintDefaultWidth == 0) {
|
|
measure.verticalBehavior = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
}
|
|
z3 = false;
|
|
}
|
|
if (constraintWidget.isResolvedHorizontally()) {
|
|
measure.horizontalBehavior = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
z2 = false;
|
|
}
|
|
if (constraintWidget.isResolvedVertically()) {
|
|
measure.verticalBehavior = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
z3 = false;
|
|
}
|
|
if (z4) {
|
|
if (constraintWidget.mResolvedMatchConstraintDefault[0] == 4) {
|
|
measure.horizontalBehavior = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
} else if (!z3) {
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour3 = measure.verticalBehavior;
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour4 = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
if (dimensionBehaviour3 == dimensionBehaviour4) {
|
|
i3 = measure.verticalDimension;
|
|
} else {
|
|
measure.horizontalBehavior = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
|
measurer.measure(constraintWidget, measure);
|
|
i3 = measure.measuredHeight;
|
|
}
|
|
measure.horizontalBehavior = dimensionBehaviour4;
|
|
int i4 = constraintWidget.mDimensionRatioSide;
|
|
if (i4 == 0 || i4 == -1) {
|
|
measure.horizontalDimension = (int) (constraintWidget.getDimensionRatio() * i3);
|
|
} else {
|
|
measure.horizontalDimension = (int) (constraintWidget.getDimensionRatio() / i3);
|
|
}
|
|
}
|
|
}
|
|
if (z5) {
|
|
if (constraintWidget.mResolvedMatchConstraintDefault[1] == 4) {
|
|
measure.verticalBehavior = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
} else if (!z2) {
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour5 = measure.horizontalBehavior;
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour6 = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
if (dimensionBehaviour5 == dimensionBehaviour6) {
|
|
i2 = measure.horizontalDimension;
|
|
} else {
|
|
measure.verticalBehavior = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
|
measurer.measure(constraintWidget, measure);
|
|
i2 = measure.measuredWidth;
|
|
}
|
|
measure.verticalBehavior = dimensionBehaviour6;
|
|
int i5 = constraintWidget.mDimensionRatioSide;
|
|
if (i5 == 0 || i5 == -1) {
|
|
measure.verticalDimension = (int) (i2 / constraintWidget.getDimensionRatio());
|
|
} else {
|
|
measure.verticalDimension = (int) (constraintWidget.getDimensionRatio() * i2);
|
|
}
|
|
}
|
|
}
|
|
measurer.measure(constraintWidget, measure);
|
|
constraintWidget.setWidth(measure.measuredWidth);
|
|
constraintWidget.setHeight(measure.measuredHeight);
|
|
constraintWidget.setHasBaseline(measure.measuredHasBaseline);
|
|
constraintWidget.setBaselineDistance(measure.measuredBaseline);
|
|
measure.measureStrategy = BasicMeasure.Measure.SELF_DIMENSIONS;
|
|
return measure.measuredNeedsSolverPass;
|
|
}
|
|
|
|
private void resetChains() {
|
|
this.mHorizontalChainsSize = 0;
|
|
this.mVerticalChainsSize = 0;
|
|
}
|
|
|
|
public void addChain(ConstraintWidget constraintWidget, int i) {
|
|
if (i == 0) {
|
|
addHorizontalChain(constraintWidget);
|
|
} else if (i == 1) {
|
|
addVerticalChain(constraintWidget);
|
|
}
|
|
}
|
|
|
|
public boolean addChildrenToSolver(LinearSystem linearSystem) {
|
|
boolean optimizeFor = optimizeFor(64);
|
|
addToSolver(linearSystem, optimizeFor);
|
|
int size = this.mChildren.size();
|
|
boolean z2 = false;
|
|
for (int i = 0; i < size; i++) {
|
|
ConstraintWidget constraintWidget = this.mChildren.get(i);
|
|
constraintWidget.setInBarrier(0, false);
|
|
constraintWidget.setInBarrier(1, false);
|
|
if (constraintWidget instanceof Barrier) {
|
|
z2 = true;
|
|
}
|
|
}
|
|
if (z2) {
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
ConstraintWidget constraintWidget2 = this.mChildren.get(i2);
|
|
if (constraintWidget2 instanceof Barrier) {
|
|
((Barrier) constraintWidget2).markWidgets();
|
|
}
|
|
}
|
|
}
|
|
for (int i3 = 0; i3 < size; i3++) {
|
|
ConstraintWidget constraintWidget3 = this.mChildren.get(i3);
|
|
if (constraintWidget3.addFirst()) {
|
|
constraintWidget3.addToSolver(linearSystem, optimizeFor);
|
|
}
|
|
}
|
|
if (LinearSystem.USE_DEPENDENCY_ORDERING) {
|
|
HashSet<ConstraintWidget> hashSet = new HashSet<>();
|
|
for (int i4 = 0; i4 < size; i4++) {
|
|
ConstraintWidget constraintWidget4 = this.mChildren.get(i4);
|
|
if (!constraintWidget4.addFirst()) {
|
|
hashSet.add(constraintWidget4);
|
|
}
|
|
}
|
|
addChildrenToSolverByDependency(this, linearSystem, hashSet, getHorizontalDimensionBehaviour() == ConstraintWidget.DimensionBehaviour.WRAP_CONTENT ? 0 : 1, false);
|
|
Iterator<ConstraintWidget> it = hashSet.iterator();
|
|
while (it.hasNext()) {
|
|
ConstraintWidget next = it.next();
|
|
Optimizer.checkMatchParent(this, linearSystem, next);
|
|
next.addToSolver(linearSystem, optimizeFor);
|
|
}
|
|
} else {
|
|
for (int i5 = 0; i5 < size; i5++) {
|
|
ConstraintWidget constraintWidget5 = this.mChildren.get(i5);
|
|
if (constraintWidget5 instanceof ConstraintWidgetContainer) {
|
|
ConstraintWidget.DimensionBehaviour[] dimensionBehaviourArr = constraintWidget5.mListDimensionBehaviors;
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour = dimensionBehaviourArr[0];
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour2 = dimensionBehaviourArr[1];
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour3 = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
|
if (dimensionBehaviour == dimensionBehaviour3) {
|
|
constraintWidget5.setHorizontalDimensionBehaviour(ConstraintWidget.DimensionBehaviour.FIXED);
|
|
}
|
|
if (dimensionBehaviour2 == dimensionBehaviour3) {
|
|
constraintWidget5.setVerticalDimensionBehaviour(ConstraintWidget.DimensionBehaviour.FIXED);
|
|
}
|
|
constraintWidget5.addToSolver(linearSystem, optimizeFor);
|
|
if (dimensionBehaviour == dimensionBehaviour3) {
|
|
constraintWidget5.setHorizontalDimensionBehaviour(dimensionBehaviour);
|
|
}
|
|
if (dimensionBehaviour2 == dimensionBehaviour3) {
|
|
constraintWidget5.setVerticalDimensionBehaviour(dimensionBehaviour2);
|
|
}
|
|
} else {
|
|
Optimizer.checkMatchParent(this, linearSystem, constraintWidget5);
|
|
if (!constraintWidget5.addFirst()) {
|
|
constraintWidget5.addToSolver(linearSystem, optimizeFor);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (this.mHorizontalChainsSize > 0) {
|
|
Chain.applyChainConstraints(this, linearSystem, null, 0);
|
|
}
|
|
if (this.mVerticalChainsSize > 0) {
|
|
Chain.applyChainConstraints(this, linearSystem, null, 1);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public void addHorizontalWrapMaxVariable(ConstraintAnchor constraintAnchor) {
|
|
WeakReference<ConstraintAnchor> weakReference = this.horizontalWrapMax;
|
|
if (weakReference == null || weakReference.get() == null || constraintAnchor.getFinalValue() > this.horizontalWrapMax.get().getFinalValue()) {
|
|
this.horizontalWrapMax = new WeakReference<>(constraintAnchor);
|
|
}
|
|
}
|
|
|
|
public void addHorizontalWrapMinVariable(ConstraintAnchor constraintAnchor) {
|
|
WeakReference<ConstraintAnchor> weakReference = this.horizontalWrapMin;
|
|
if (weakReference == null || weakReference.get() == null || constraintAnchor.getFinalValue() > this.horizontalWrapMin.get().getFinalValue()) {
|
|
this.horizontalWrapMin = new WeakReference<>(constraintAnchor);
|
|
}
|
|
}
|
|
|
|
public void addVerticalWrapMaxVariable(ConstraintAnchor constraintAnchor) {
|
|
WeakReference<ConstraintAnchor> weakReference = this.verticalWrapMax;
|
|
if (weakReference == null || weakReference.get() == null || constraintAnchor.getFinalValue() > this.verticalWrapMax.get().getFinalValue()) {
|
|
this.verticalWrapMax = new WeakReference<>(constraintAnchor);
|
|
}
|
|
}
|
|
|
|
public void addVerticalWrapMinVariable(ConstraintAnchor constraintAnchor) {
|
|
WeakReference<ConstraintAnchor> weakReference = this.verticalWrapMin;
|
|
if (weakReference == null || weakReference.get() == null || constraintAnchor.getFinalValue() > this.verticalWrapMin.get().getFinalValue()) {
|
|
this.verticalWrapMin = new WeakReference<>(constraintAnchor);
|
|
}
|
|
}
|
|
|
|
public void defineTerminalWidgets() {
|
|
this.mDependencyGraph.defineTerminalWidgets(getHorizontalDimensionBehaviour(), getVerticalDimensionBehaviour());
|
|
}
|
|
|
|
public boolean directMeasure(boolean z2) {
|
|
return this.mDependencyGraph.directMeasure(z2);
|
|
}
|
|
|
|
public boolean directMeasureSetup(boolean z2) {
|
|
return this.mDependencyGraph.directMeasureSetup(z2);
|
|
}
|
|
|
|
public boolean directMeasureWithOrientation(boolean z2, int i) {
|
|
return this.mDependencyGraph.directMeasureWithOrientation(z2, i);
|
|
}
|
|
|
|
public void fillMetrics(Metrics metrics) {
|
|
this.mMetrics = metrics;
|
|
this.mSystem.fillMetrics(metrics);
|
|
}
|
|
|
|
public ArrayList<Guideline> getHorizontalGuidelines() {
|
|
ArrayList<Guideline> arrayList = new ArrayList<>();
|
|
int size = this.mChildren.size();
|
|
for (int i = 0; i < size; i++) {
|
|
ConstraintWidget constraintWidget = this.mChildren.get(i);
|
|
if (constraintWidget instanceof Guideline) {
|
|
Guideline guideline = (Guideline) constraintWidget;
|
|
if (guideline.getOrientation() == 0) {
|
|
arrayList.add(guideline);
|
|
}
|
|
}
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
public BasicMeasure.Measurer getMeasurer() {
|
|
return this.mMeasurer;
|
|
}
|
|
|
|
public int getOptimizationLevel() {
|
|
return this.mOptimizationLevel;
|
|
}
|
|
|
|
public LinearSystem getSystem() {
|
|
return this.mSystem;
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.solver.widgets.ConstraintWidget
|
|
public String getType() {
|
|
return "ConstraintLayout";
|
|
}
|
|
|
|
public ArrayList<Guideline> getVerticalGuidelines() {
|
|
ArrayList<Guideline> arrayList = new ArrayList<>();
|
|
int size = this.mChildren.size();
|
|
for (int i = 0; i < size; i++) {
|
|
ConstraintWidget constraintWidget = this.mChildren.get(i);
|
|
if (constraintWidget instanceof Guideline) {
|
|
Guideline guideline = (Guideline) constraintWidget;
|
|
if (guideline.getOrientation() == 1) {
|
|
arrayList.add(guideline);
|
|
}
|
|
}
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
public boolean handlesInternalConstraints() {
|
|
return false;
|
|
}
|
|
|
|
public void invalidateGraph() {
|
|
this.mDependencyGraph.invalidateGraph();
|
|
}
|
|
|
|
public void invalidateMeasures() {
|
|
this.mDependencyGraph.invalidateMeasures();
|
|
}
|
|
|
|
public boolean isHeightMeasuredTooSmall() {
|
|
return this.mHeightMeasuredTooSmall;
|
|
}
|
|
|
|
public boolean isRtl() {
|
|
return this.mIsRtl;
|
|
}
|
|
|
|
public boolean isWidthMeasuredTooSmall() {
|
|
return this.mWidthMeasuredTooSmall;
|
|
}
|
|
|
|
/* JADX WARN: Unknown variable types count: 1 */
|
|
@Override // androidx.constraintlayout.solver.widgets.WidgetContainer
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
*/
|
|
public void layout() {
|
|
boolean z2;
|
|
?? r6;
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour;
|
|
this.mX = 0;
|
|
this.mY = 0;
|
|
this.mWidthMeasuredTooSmall = false;
|
|
this.mHeightMeasuredTooSmall = false;
|
|
int size = this.mChildren.size();
|
|
int max = Math.max(0, getWidth());
|
|
int max2 = Math.max(0, getHeight());
|
|
ConstraintWidget.DimensionBehaviour[] dimensionBehaviourArr = this.mListDimensionBehaviors;
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour2 = dimensionBehaviourArr[1];
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour3 = dimensionBehaviourArr[0];
|
|
Metrics metrics = this.mMetrics;
|
|
if (metrics != null) {
|
|
metrics.layouts++;
|
|
}
|
|
if (Optimizer.enabled(this.mOptimizationLevel, 1)) {
|
|
Direct.solvingPass(this, getMeasurer());
|
|
for (int i = 0; i < size; i++) {
|
|
ConstraintWidget constraintWidget = this.mChildren.get(i);
|
|
if (constraintWidget.isMeasureRequested() && !(constraintWidget instanceof Guideline) && !(constraintWidget instanceof Barrier) && !(constraintWidget instanceof VirtualLayout) && !constraintWidget.isInVirtualLayout()) {
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour4 = constraintWidget.getDimensionBehaviour(0);
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour5 = constraintWidget.getDimensionBehaviour(1);
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour6 = ConstraintWidget.DimensionBehaviour.MATCH_CONSTRAINT;
|
|
if (!(dimensionBehaviour4 == dimensionBehaviour6 && constraintWidget.mMatchConstraintDefaultWidth != 1 && dimensionBehaviour5 == dimensionBehaviour6 && constraintWidget.mMatchConstraintDefaultHeight != 1)) {
|
|
measure(constraintWidget, this.mMeasurer, new BasicMeasure.Measure(), BasicMeasure.Measure.SELF_DIMENSIONS);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (size <= 2 || (!(dimensionBehaviour3 == (dimensionBehaviour = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT) || dimensionBehaviour2 == dimensionBehaviour) || !Optimizer.enabled(this.mOptimizationLevel, 1024) || !Grouping.simpleSolvingPass(this, getMeasurer()))) {
|
|
max2 = max2;
|
|
max = max;
|
|
z2 = false;
|
|
} else {
|
|
if (dimensionBehaviour3 == dimensionBehaviour) {
|
|
if (max >= getWidth() || max <= 0) {
|
|
max = getWidth();
|
|
} else {
|
|
setWidth(max);
|
|
this.mWidthMeasuredTooSmall = true;
|
|
}
|
|
}
|
|
if (dimensionBehaviour2 == dimensionBehaviour) {
|
|
if (max2 >= getHeight() || max2 <= 0) {
|
|
max2 = getHeight();
|
|
} else {
|
|
setHeight(max2);
|
|
this.mHeightMeasuredTooSmall = true;
|
|
}
|
|
}
|
|
z2 = true;
|
|
}
|
|
boolean z3 = optimizeFor(64) || optimizeFor(128);
|
|
LinearSystem linearSystem = this.mSystem;
|
|
linearSystem.graphOptimizer = false;
|
|
linearSystem.newgraphOptimizer = false;
|
|
if (this.mOptimizationLevel != 0 && z3) {
|
|
linearSystem.newgraphOptimizer = true;
|
|
}
|
|
ArrayList<ConstraintWidget> arrayList = this.mChildren;
|
|
ConstraintWidget.DimensionBehaviour horizontalDimensionBehaviour = getHorizontalDimensionBehaviour();
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour7 = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
|
boolean z4 = horizontalDimensionBehaviour == dimensionBehaviour7 || getVerticalDimensionBehaviour() == dimensionBehaviour7;
|
|
resetChains();
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
ConstraintWidget constraintWidget2 = this.mChildren.get(i2);
|
|
if (constraintWidget2 instanceof WidgetContainer) {
|
|
((WidgetContainer) constraintWidget2).layout();
|
|
}
|
|
}
|
|
boolean optimizeFor = optimizeFor(64);
|
|
int i3 = 0;
|
|
boolean z5 = true;
|
|
while (z5) {
|
|
int i4 = i3 + 1;
|
|
try {
|
|
this.mSystem.reset();
|
|
resetChains();
|
|
createObjectVariables(this.mSystem);
|
|
for (int i5 = 0; i5 < size; i5++) {
|
|
this.mChildren.get(i5).createObjectVariables(this.mSystem);
|
|
}
|
|
z5 = addChildrenToSolver(this.mSystem);
|
|
WeakReference<ConstraintAnchor> weakReference = this.verticalWrapMin;
|
|
if (!(weakReference == null || weakReference.get() == null)) {
|
|
addMinWrap(this.verticalWrapMin.get(), this.mSystem.createObjectVariable(this.mTop));
|
|
this.verticalWrapMin = null;
|
|
}
|
|
WeakReference<ConstraintAnchor> weakReference2 = this.verticalWrapMax;
|
|
if (!(weakReference2 == null || weakReference2.get() == null)) {
|
|
addMaxWrap(this.verticalWrapMax.get(), this.mSystem.createObjectVariable(this.mBottom));
|
|
this.verticalWrapMax = null;
|
|
}
|
|
WeakReference<ConstraintAnchor> weakReference3 = this.horizontalWrapMin;
|
|
if (!(weakReference3 == null || weakReference3.get() == null)) {
|
|
addMinWrap(this.horizontalWrapMin.get(), this.mSystem.createObjectVariable(this.mLeft));
|
|
this.horizontalWrapMin = null;
|
|
}
|
|
WeakReference<ConstraintAnchor> weakReference4 = this.horizontalWrapMax;
|
|
if (!(weakReference4 == null || weakReference4.get() == null)) {
|
|
addMaxWrap(this.horizontalWrapMax.get(), this.mSystem.createObjectVariable(this.mRight));
|
|
this.horizontalWrapMax = null;
|
|
}
|
|
if (z5) {
|
|
this.mSystem.minimize();
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
System.out.println("EXCEPTION : " + e);
|
|
}
|
|
if (z5) {
|
|
updateChildrenFromSolver(this.mSystem, Optimizer.flags);
|
|
} else {
|
|
updateFromSolver(this.mSystem, optimizeFor);
|
|
for (int i6 = 0; i6 < size; i6++) {
|
|
this.mChildren.get(i6).updateFromSolver(this.mSystem, optimizeFor);
|
|
}
|
|
}
|
|
if (!z4 || i4 >= 8 || !Optimizer.flags[2]) {
|
|
z5 = false;
|
|
} else {
|
|
int i7 = 0;
|
|
int i8 = 0;
|
|
for (int i9 = 0; i9 < size; i9++) {
|
|
ConstraintWidget constraintWidget3 = this.mChildren.get(i9);
|
|
i7 = Math.max(i7, constraintWidget3.getWidth() + constraintWidget3.mX);
|
|
i8 = Math.max(i8, constraintWidget3.getHeight() + constraintWidget3.mY);
|
|
}
|
|
int max3 = Math.max(this.mMinWidth, i7);
|
|
int max4 = Math.max(this.mMinHeight, i8);
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour8 = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
|
if (dimensionBehaviour3 != dimensionBehaviour8 || getWidth() >= max3) {
|
|
z5 = false;
|
|
} else {
|
|
setWidth(max3);
|
|
this.mListDimensionBehaviors[0] = dimensionBehaviour8;
|
|
z5 = true;
|
|
z2 = true;
|
|
}
|
|
if (dimensionBehaviour2 == dimensionBehaviour8 && getHeight() < max4) {
|
|
setHeight(max4);
|
|
this.mListDimensionBehaviors[1] = dimensionBehaviour8;
|
|
z5 = true;
|
|
z2 = true;
|
|
}
|
|
}
|
|
int max5 = Math.max(this.mMinWidth, getWidth());
|
|
if (max5 > getWidth()) {
|
|
setWidth(max5);
|
|
this.mListDimensionBehaviors[0] = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
z5 = true;
|
|
z2 = true;
|
|
}
|
|
int max6 = Math.max(this.mMinHeight, getHeight());
|
|
if (max6 > getHeight()) {
|
|
setHeight(max6);
|
|
r6 = 1;
|
|
this.mListDimensionBehaviors[1] = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
z5 = true;
|
|
z2 = true;
|
|
} else {
|
|
r6 = 1;
|
|
}
|
|
if (!z2) {
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour9 = this.mListDimensionBehaviors[0];
|
|
ConstraintWidget.DimensionBehaviour dimensionBehaviour10 = ConstraintWidget.DimensionBehaviour.WRAP_CONTENT;
|
|
if (dimensionBehaviour9 == dimensionBehaviour10 && max > 0 && getWidth() > max) {
|
|
this.mWidthMeasuredTooSmall = r6;
|
|
this.mListDimensionBehaviors[0] = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
setWidth(max);
|
|
z5 = true;
|
|
z2 = true;
|
|
}
|
|
ConstraintWidget.DimensionBehaviour[] dimensionBehaviourArr2 = this.mListDimensionBehaviors;
|
|
char c = r6 == true ? 1 : 0;
|
|
char c2 = r6 == true ? 1 : 0;
|
|
char c3 = r6 == true ? 1 : 0;
|
|
if (dimensionBehaviourArr2[c] == dimensionBehaviour10 && max2 > 0 && getHeight() > max2) {
|
|
this.mHeightMeasuredTooSmall = r6;
|
|
this.mListDimensionBehaviors[r6] = ConstraintWidget.DimensionBehaviour.FIXED;
|
|
setHeight(max2);
|
|
z2 = true;
|
|
z5 = true;
|
|
i3 = i4;
|
|
}
|
|
}
|
|
i3 = i4;
|
|
}
|
|
this.mChildren = arrayList;
|
|
if (z2) {
|
|
ConstraintWidget.DimensionBehaviour[] dimensionBehaviourArr3 = this.mListDimensionBehaviors;
|
|
dimensionBehaviourArr3[0] = dimensionBehaviour3;
|
|
dimensionBehaviourArr3[1] = dimensionBehaviour2;
|
|
}
|
|
resetSolverVariables(this.mSystem.getCache());
|
|
}
|
|
|
|
public long measure(int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9) {
|
|
this.mPaddingLeft = i8;
|
|
this.mPaddingTop = i9;
|
|
return this.mBasicMeasureSolver.solverMeasure(this, i, i8, i9, i2, i3, i4, i5, i6, i7);
|
|
}
|
|
|
|
public boolean optimizeFor(int i) {
|
|
return (this.mOptimizationLevel & i) == i;
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.solver.widgets.WidgetContainer, androidx.constraintlayout.solver.widgets.ConstraintWidget
|
|
public void reset() {
|
|
this.mSystem.reset();
|
|
this.mPaddingLeft = 0;
|
|
this.mPaddingRight = 0;
|
|
this.mPaddingTop = 0;
|
|
this.mPaddingBottom = 0;
|
|
this.mSkipSolver = false;
|
|
super.reset();
|
|
}
|
|
|
|
public void setMeasurer(BasicMeasure.Measurer measurer) {
|
|
this.mMeasurer = measurer;
|
|
this.mDependencyGraph.setMeasurer(measurer);
|
|
}
|
|
|
|
public void setOptimizationLevel(int i) {
|
|
this.mOptimizationLevel = i;
|
|
LinearSystem.USE_DEPENDENCY_ORDERING = optimizeFor(512);
|
|
}
|
|
|
|
public void setPadding(int i, int i2, int i3, int i4) {
|
|
this.mPaddingLeft = i;
|
|
this.mPaddingTop = i2;
|
|
this.mPaddingRight = i3;
|
|
this.mPaddingBottom = i4;
|
|
}
|
|
|
|
public void setRtl(boolean z2) {
|
|
this.mIsRtl = z2;
|
|
}
|
|
|
|
public void updateChildrenFromSolver(LinearSystem linearSystem, boolean[] zArr) {
|
|
zArr[2] = false;
|
|
boolean optimizeFor = optimizeFor(64);
|
|
updateFromSolver(linearSystem, optimizeFor);
|
|
int size = this.mChildren.size();
|
|
for (int i = 0; i < size; i++) {
|
|
this.mChildren.get(i).updateFromSolver(linearSystem, optimizeFor);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.constraintlayout.solver.widgets.ConstraintWidget
|
|
public void updateFromRuns(boolean z2, boolean z3) {
|
|
super.updateFromRuns(z2, z3);
|
|
int size = this.mChildren.size();
|
|
for (int i = 0; i < size; i++) {
|
|
this.mChildren.get(i).updateFromRuns(z2, z3);
|
|
}
|
|
}
|
|
|
|
public void updateHierarchy() {
|
|
this.mBasicMeasureSolver.updateHierarchy(this);
|
|
}
|
|
}
|