Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

revert flow #491

Merged
merged 1 commit into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
<enum name="none" value="0" />
<enum name="chain" value="1" />
<enum name="aligned" value="2" />
<enum name="deprecatedChain" value="3" />
<enum name="chain2" value="3" />
</attr>

<!-- if defined, wrap after max elements -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public static int rgbaTocColor(float r, float g, float b, float a) {
int color = (ia << 24) | (ir << 16) | (ig << 8) | ib;
return color;
}
public interface DebugHandle {
void message(String str);
}
static DebugHandle ourHandle;
public static void setDebugHandle(DebugHandle handle) {
ourHandle = handle;
}
public static void logStack(String msg, int n) {
StackTraceElement[] st = new Throwable().getStackTrace();
String s = " ";
Expand All @@ -83,6 +90,9 @@ public static void log(String str) {
String npad = " ".substring(Integer.toString(s.getLineNumber()).length());
String ss = ".(" + s.getFileName() + ":" + s.getLineNumber() + ")" + npad +methodName;
System.out.println(ss + " " + str);
if (ourHandle != null) {
ourHandle.message(ss + " " + str);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class Flow extends VirtualLayout {
public static final int WRAP_NONE = 0;
public static final int WRAP_CHAIN = 1;
public static final int WRAP_ALIGNED = 2;
public static final int WRAP_CHAIN_DEPRECATED = 3;
public static final int WRAP_CHAIN_NEW = 3;

private int mHorizontalStyle = UNKNOWN;
private int mVerticalStyle = UNKNOWN;
Expand Down Expand Up @@ -170,6 +170,9 @@ public void setWrapMode(int value) {

public void setMaxElementsWrap(int value) { mMaxElementsWrap = value; }

public float getMaxElementsWrap() {
return mMaxElementsWrap;
}
/////////////////////////////////////////////////////////////////////////////////////////////
// Utility methods
/////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -293,14 +296,15 @@ public void measure(int widthMode, int widthSize, int heightMode, int heightSize
measureChainWrap(widgets, count, mOrientation, max, measured);
}
break;
case WRAP_CHAIN_DEPRECATED: {
measureChainWrap_broken(widgets, count, mOrientation, max, measured);
}
break;
case WRAP_NONE: {
measureNoWrap(widgets, count, mOrientation, max, measured);
}
break;
case WRAP_CHAIN_NEW: {
measureChainWrap_new(widgets, count, mOrientation, max, measured);
}
break;

}

width = measured[HORIZONTAL] + paddingLeft + paddingRight;
Expand Down Expand Up @@ -785,7 +789,7 @@ private void recomputeDimensions() {
* @param max the maximum available space
* @param measured output parameters -- will contain the resulting measure
*/
private void measureChainWrap_broken(ConstraintWidget[] widgets, int count, int orientation, int max, int[] measured) {
private void measureChainWrap(ConstraintWidget[] widgets, int count, int orientation, int max, int[] measured) {
if (count == 0) {
return;
}
Expand Down Expand Up @@ -926,18 +930,18 @@ private void measureChainWrap_broken(ConstraintWidget[] widgets, int count, int
measured[VERTICAL] = maxHeight;
}
/////////////////////////////////////////////////////////////////////////////////////////////
// Measure Chain Wrap
// Measure Chain Wrap new
/////////////////////////////////////////////////////////////////////////////////////////////

/**
* Measure the virtual layout using a list of chains for the children
* Measure the virtual layout using a list of chains for the children in new "fixed way"
* @param widgets list of widgets
* @param count
* @param orientation the layout orientation (horizontal or vertical)
* @param max the maximum available space
* @param measured output parameters -- will contain the resulting measure
*/
private void measureChainWrap(ConstraintWidget[] widgets, int count, int orientation, int max, int[] measured) {
private void measureChainWrap_new(ConstraintWidget[] widgets, int count, int orientation, int max, int[] measured) {
if (count == 0) {
return;
}
Expand Down Expand Up @@ -1406,6 +1410,14 @@ public void addToSolver(LinearSystem system, boolean optimize) {
case WRAP_ALIGNED: {
createAlignedConstraints(isInRtl);
}
break;
case WRAP_CHAIN_NEW: {
final int count = mChainList.size();
for (int i = 0; i < count; i++) {
WidgetsList list = mChainList.get(i);
list.createConstraints(isInRtl, i, i == count - 1);
}
} break;
}
needsCallbackFromSolver(false);
}
Expand Down