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

fix error prone #629

Merged
merged 2 commits into from
Jun 17, 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 @@ -261,8 +261,8 @@ public static class CustomSet extends ViewTimeCycle {
SparseArray<ConstraintAttribute> mConstraintAttributeList;
SparseArray<float[]> mWaveProperties = new SparseArray<>();
float[] mTempValues;
float[] mCache;

@SuppressWarnings("StringSplitter")
public CustomSet(String attribute, SparseArray<ConstraintAttribute> attrList) {
mAttributeName = attribute.split(",")[1];
mConstraintAttributeList = attrList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ public Key copy(Key src) {
mTranslationY = k.mTranslationY;
mTranslationZ = k.mTranslationZ;
mProgress = k.mProgress;
mTransitionEasing = k.mTransitionEasing;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ public Key copy(Key src) {
mTranslationX = k.mTranslationX;
mTranslationY = k.mTranslationY;
mTranslationZ = k.mTranslationZ;
mCustomWaveShape = k.mCustomWaveShape;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,19 +809,6 @@ public boolean isEnabled() {
return !mDisable;
}

/**
* Enable or disable the Transition. If a Transition is disabled it is not eligible
* for automatically switching to.
*
* @param enable
* deprecated This method should be called {@code setEnabled}, so that {@code isEnabled}
* can be accessed as a <a href="https://developer.android.com/kotlin/interop#property_prefixes">property from Kotlin</a>.
* Use {@link #setEnabled(boolean)} instead.
*/
private void setEnable(boolean enable) {
setEnabled(enable);
}

/**
* enable or disable the Transition. If a Transition is disabled it is not eligible
* for automatically switching to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ private void warmth(float warmth) {
float colorR, colorG, colorB;
if (centiKelvin > 66) {
float tmp = centiKelvin - 60.f;
colorR = (329.698727446f * (float) Math.pow(tmp, -0.1332047592f));
// colorR = (329.698727446f * (float) Math.pow(tmp, -0.1332047592f))
// colorG = (288.1221695283f * (float) Math.pow(tmp, 0.0755148492f))
colorR = (329.69873f * (float) Math.pow(tmp, -0.1332047592f));
colorG = (288.1221695283f * (float) Math.pow(tmp, 0.0755148492f));

} else {
Expand All @@ -153,8 +155,9 @@ private void warmth(float warmth) {
}
if (centiKelvin < 66) {
if (centiKelvin > 19) {
colorB = (138.5177312231f
* (float) Math.log(centiKelvin - 10) - 305.0447927307f);
// 138.5177312231f * (float) Math.log(centiKelvin - 10) - 305.0447927307f);
colorB = (138.51773f
* (float) Math.log(centiKelvin - 10) - 305.0448f);
} else {
colorB = 0;
}
Expand All @@ -175,17 +178,20 @@ private void warmth(float warmth) {
float colorR, colorG, colorB;
if (centiKelvin > 66) {
float tmp = centiKelvin - 60.f;
colorR = (329.698727446f * (float) Math.pow(tmp, -0.1332047592f));
colorG = (288.1221695283f * (float) Math.pow(tmp, 0.0755148492f));
// colorR = (329.698727446f * (float) Math.pow(tmp, -0.1332047592f));
// colorG = (288.1221695283f * (float) Math.pow(tmp, 0.0755148492f));
colorR = (329.69873f * (float) Math.pow(tmp, -0.13320476f));
colorG = (288.12216f * (float) Math.pow(tmp, 0.075514849f));

} else {
colorG = (99.4708025861f * (float) Math.log(centiKelvin) - 161.1195681661f);
//float of (99.4708025861f * (float) Math.log(centiKelvin) - 161.1195681661f);
colorG = (99.4708f * (float) Math.log(centiKelvin) - 161.11957f);
colorR = 255;
}
if (centiKelvin < 66) {
if (centiKelvin > 19) {
colorB = (138.5177312231f
* (float) Math.log(centiKelvin - 10) - 305.0447927307f);
//float of (138.5177312231 * Math.log(centiKelvin - 10) - 305.0447927307);
colorB = (138.51773f * (float) Math.log(centiKelvin - 10) - 305.0448f);
} else {
colorB = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public abstract class ConstraintHelper extends View {
*/
private View[] mViews = null;

/**
* @DoNotShow
*/
protected final static String CHILD_TAG = "CONSTRAINT_LAYOUT_HELPER_CHILD";

protected HashMap<Integer, String> mMap = new HashMap<>();

public ConstraintHelper(Context context) {
Expand Down Expand Up @@ -702,4 +707,15 @@ public int indexFromId(final int id) {
}
return index;
}

/**
* hook for helpers to apply parameters in MotionLayout
*/
public void applyHelperParams() {

}

public static boolean isChildOfHelper(View v) {
return CHILD_TAG == v.getTag();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ public class ConstraintLayout extends ViewGroup {
* @DoNotShow
*/
public static final int DESIGN_INFO_ID = 0;
private ConstraintsChangedListener mConstraintsChangedListener;
// private ConstraintsChangedListener mConstraintsChangedListener;
private Metrics mMetrics;

private static SharedValues sSharedValues = null;
Expand Down Expand Up @@ -802,7 +802,7 @@ public final void measure(ConstraintWidget widget,
|| !shouldDoWrap
|| (shouldDoWrap && otherDimensionStable)
|| (child instanceof Placeholder)
|| (widget.isResolvedHorizontally());
|| widget.isResolvedHorizontally();
if (useCurrent) {
horizontalSpec = MeasureSpec.makeMeasureSpec(widget.getWidth(),
MeasureSpec.EXACTLY);
Expand Down Expand Up @@ -851,7 +851,7 @@ public final void measure(ConstraintWidget widget,
|| !shouldDoWrap
|| (shouldDoWrap && otherDimensionStable)
|| (child instanceof Placeholder)
|| (widget.isResolvedVertically());
|| widget.isResolvedVertically();
if (useCurrent) {
verticalSpec = MeasureSpec.makeMeasureSpec(widget.getHeight(),
MeasureSpec.EXACTLY);
Expand Down Expand Up @@ -2195,6 +2195,7 @@ protected void dispatchDraw(Canvas canvas) {
Object tag = child.getTag();
if (tag != null && tag instanceof String) {
String coordinates = (String) tag;
@SuppressWarnings("StringSplitter")
String[] split = coordinates.split(",");
if (split.length == 4) {
int x = Integer.parseInt(split[0]);
Expand Down Expand Up @@ -2267,7 +2268,7 @@ protected void dispatchDraw(Canvas canvas) {
* @param constraintsChangedListener
*/
public void setOnConstraintsChanged(ConstraintsChangedListener constraintsChangedListener) {
this.mConstraintsChangedListener = constraintsChangedListener;
// this.mConstraintsChangedListener = constraintsChangedListener;
if (mConstraintLayoutSpec != null) {
mConstraintLayoutSpec.setOnConstraintsChanged(constraintsChangedListener);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2981,7 +2981,6 @@ public void createVerticalChain(int topId,

connect(chainIds[0], TOP, topId, topSide, 0);
for (int i = 1; i < chainIds.length; i++) {
int chainId = chainIds[i];
connect(chainIds[i], TOP, chainIds[i - 1], BOTTOM, 0);
connect(chainIds[i - 1], BOTTOM, chainIds[i], TOP, 0);
if (weights != null) {
Expand Down Expand Up @@ -3063,7 +3062,6 @@ private void createHorizontalChain(int leftId,
get(chainIds[0]).layout.horizontalChainStyle = style;
connect(chainIds[0], left, leftId, leftSide, UNSET);
for (int i = 1; i < chainIds.length; i++) {
int chainId = chainIds[i];
connect(chainIds[i], left, chainIds[i - 1], right, UNSET);
connect(chainIds[i - 1], right, chainIds[i], left, UNSET);
if (weights != null) {
Expand Down Expand Up @@ -4587,7 +4585,7 @@ public void load(Context context, XmlPullParser parser) {
case XmlResourceParser.START_TAG:
tagName = parser.getName();
if (DEBUG) {
Log.v(TAG, Debug.getLoc() + " view .... tagName=" + tagName);
Log.v(TAG, Debug.getLoc() + " " + document + " tagName=" + tagName);
}
switch (tagName) {
case "Constraint":
Expand Down Expand Up @@ -4717,12 +4715,12 @@ public static Constraint buildDelta(Context context, XmlPullParser parser) {
AttributeSet attrs = Xml.asAttributeSet(parser);
Constraint c = new Constraint();
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ConstraintOverride);
populateOverride(context, c, a);
populateOverride(c, a);
a.recycle();
return c;
}

private static void populateOverride(Context ctx, Constraint c, TypedArray a) {
private static void populateOverride(Constraint c, TypedArray a) {

final int count = a.getIndexCount();
TypedValue type;
Expand Down Expand Up @@ -5354,7 +5352,7 @@ private static void setDeltaValue(Constraint c, int type, boolean value) {

private void populateConstraint(Context ctx, Constraint c, TypedArray a, boolean override) {
if (override) {
populateOverride(ctx, c, a);
populateOverride(c, a);
return;
}
final int count = a.getIndexCount();
Expand Down Expand Up @@ -5851,6 +5849,16 @@ public void setValidateOnParse(boolean validate) {
mValidate = validate;
}

/**
* If true perform validation checks when parsing ConstraintSets
* This will slow down parsing and should only be used for debugging
*
* @param validate
*/
public boolean isValidateOnParse() {
return mValidate;
}

/**
* Dump the contents
*
Expand Down Expand Up @@ -6322,7 +6330,12 @@ void writeLayout() throws IOException {
private void writeGuideline(int orientation,
int guideBegin,
int guideEnd,
float guidePercent) {
float guidePercent) throws IOException {
writeVariable("'orientation'", orientation);
writeVariable("'guideBegin'", guideBegin);
writeVariable("'guideEnd'", guideEnd);
writeVariable("'guidePercent'", guidePercent);

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ArrayLinkedVariables implements ArrayRow.ArrayRowVariables {
private static final boolean DEBUG = false;

static final int NONE = -1;
private static final boolean FULL_NEW_CHECK = false; // full validation (debug purposes)
// private static final boolean FULL_NEW_CHECK = false full validation (debug purposes)

int mCurrentSize = 0; // current size, accessed by ArrayRow and LinearSystem

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class LinearSystem {
public static Metrics sMetrics;
private Row mTempGoal;

class ValuesRow extends ArrayRow {
static class ValuesRow extends ArrayRow {
ValuesRow(Cache cache) {
variables = new SolverVariableValues(this, cache);
}
Expand Down Expand Up @@ -328,13 +328,13 @@ public SolverVariable createExtraVariable() {
return variable;
}

private void addError(ArrayRow row) {
row.addError(this, SolverVariable.STRENGTH_NONE);
}

private void addSingleError(ArrayRow row, int sign) {
addSingleError(row, sign, SolverVariable.STRENGTH_NONE);
}
// private void addError(ArrayRow row)
// row.addError(this, SolverVariable.STRENGTH_NONE);
//
//
// private void addSingleError(ArrayRow row, int sign)
// addSingleError(row, sign, SolverVariable.STRENGTH_NONE);
//

void addSingleError(ArrayRow row, int sign, int strength) {
String prefix = null;
Expand Down Expand Up @@ -767,7 +767,7 @@ private int optimize(Row goal, boolean b) {
System.out.println("\n****************************");
System.out.println("* OPTIMIZATION *");
System.out.println("* mNumColumns: " + mNumColumns);
System.out.println("* GOAL: " + goal);
System.out.println("* GOAL: " + goal + " " + b);
System.out.println("****************************\n");
}

Expand Down Expand Up @@ -1402,11 +1402,11 @@ public void addSynonym(SolverVariable a, SolverVariable b, int margin) {
System.out.println("(S) -> " + a + " = " + b + (margin != 0 ? " + " + margin : ""));
}
if (b.mIsSynonym) {
margin += b.mSynonymDelta;
margin += (int) b.mSynonymDelta;
b = mCache.mIndexedVariables[b.mSynonym];
}
if (a.mIsSynonym) {
margin -= a.mSynonymDelta;
margin -= (int) a.mSynonymDelta;
a = mCache.mIndexedVariables[a.mSynonym];
} else {
a.setSynonym(this, b, 0);
Expand Down Expand Up @@ -1441,11 +1441,11 @@ public ArrayRow addEquality(SolverVariable a, SolverVariable b, int margin, int
+ " " + getDisplayStrength(strength));
}
if (b.mIsSynonym) {
margin += b.mSynonymDelta;
margin += (int) b.mSynonymDelta;
b = mCache.mIndexedVariables[b.mSynonym];
}
if (a.mIsSynonym) {
margin -= a.mSynonymDelta;
margin -= (int) a.mSynonymDelta;
a = mCache.mIndexedVariables[a.mSynonym];
} else {
a.setSynonym(this, b, margin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ public ArrayList<String> getErrors() {
return mErrors;
}

@Override
public String getMessage() { return toString(); }

@Override
public String toString() {
return "IncorrectConstraintException: " + mErrors.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
* Utility class to encapsulate layout of a widget
*/
public class WidgetFrame {
private static final boolean OLD_SYSTEM = true;
public ConstraintWidget widget = null;
public int left = 0;
public int top = 0;
Expand Down Expand Up @@ -164,8 +163,8 @@ public static void interpolate(int parentWidth,

if (start.visibility == ConstraintWidget.GONE) {
// On visibility gone, keep the same size to do an alpha to zero
startX -= endWidth / 2f;
startY -= endHeight / 2f;
startX -= (int) (endWidth / 2f);
startY -= (int) (endHeight / 2f);
startWidth = endWidth;
startHeight = endHeight;
if (Float.isNaN(startAlpha)) {
Expand All @@ -176,8 +175,8 @@ public static void interpolate(int parentWidth,

if (end.visibility == ConstraintWidget.GONE) {
// On visibility gone, keep the same size to do an alpha to zero
endX -= startWidth / 2f;
endY -= startHeight / 2f;
endX -= (int) (startWidth / 2f);
endY -= (int) (startHeight / 2f);
endWidth = startWidth;
endHeight = startHeight;
if (Float.isNaN(endAlpha)) {
Expand Down Expand Up @@ -512,11 +511,11 @@ void parseCustom(CLElement custom) throws CLParsingException {
String vStr = v.content();
if (vStr.matches("#[0-9a-fA-F]+")) {
int color = Integer.parseInt(vStr.substring(1), 16);
setCustomAttribute(k.content(), TypedValues.Custom.TYPE_COLOR, color);
setCustomAttribute(name, TypedValues.Custom.TYPE_COLOR, color);
} else if (v instanceof CLNumber) {
setCustomAttribute(k.content(), TypedValues.Custom.TYPE_FLOAT, v.getFloat());
setCustomAttribute(name, TypedValues.Custom.TYPE_FLOAT, v.getFloat());
} else {
setCustomAttribute(k.content(), TypedValues.Custom.TYPE_STRING, vStr);
setCustomAttribute(name, TypedValues.Custom.TYPE_STRING, vStr);

}
}
Expand Down
Loading