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

Fix error-prone issues part2 #631

Merged
merged 1 commit 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 @@ -482,10 +482,10 @@ private void setMatrix() {
) {
return;
}
float panX = (Float.isNaN(mPanX)) ? 0 : mPanX;
float panY = (Float.isNaN(mPanY)) ? 0 : mPanY;
float zoom = (Float.isNaN(mZoom)) ? 1 : mZoom;
float rota = (Float.isNaN(mRotate)) ? 0 : mRotate;
float panX = Float.isNaN(mPanX) ? 0 : mPanX;
float panY = Float.isNaN(mPanY) ? 0 : mPanY;
float zoom = Float.isNaN(mZoom) ? 1 : mZoom;
float rota = Float.isNaN(mRotate) ? 0 : mRotate;
Matrix imageMatrix = new Matrix();
imageMatrix.reset();
float iw = getDrawable().getIntrinsicWidth();
Expand Down Expand Up @@ -660,7 +660,7 @@ public void setCrossfade(float crossfade) {
if (!mOverlay) {
mLayer.getDrawable(0).setAlpha((int) (255 * (1 - mCrossfade)));
}
mLayer.getDrawable(1).setAlpha((int) (255 * (mCrossfade)));
mLayer.getDrawable(1).setAlpha((int) (255 * mCrossfade));
super.setImageDrawable(mLayer);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ private void setupTexture() {
if (iw <= 0) {
int w = getWidth();
if (w == 0) {
w = ((Float.isNaN(mTextureWidth)) ? 128 : (int) mTextureWidth);
w = (Float.isNaN(mTextureWidth) ? 128 : (int) mTextureWidth);
}
iw = w;
}
if (ih <= 0) {
int h = getHeight();
if (h == 0) {
h = ((Float.isNaN(mTextureHeight)) ? 128 : (int) mTextureHeight);
h = (Float.isNaN(mTextureHeight) ? 128 : (int) mTextureHeight);
}
ih = h;
}
Expand Down Expand Up @@ -326,7 +326,7 @@ private float getHorizontalOffset() {
float scale = Float.isNaN(mBaseTextSize) ? 1.0f : mTextSize / mBaseTextSize;

float textWidth = scale * mPaint.measureText(mText, 0, mText.length());
float boxWidth = ((Float.isNaN(mFloatWidth)) ? getMeasuredWidth() : mFloatWidth)
float boxWidth = (Float.isNaN(mFloatWidth) ? getMeasuredWidth() : mFloatWidth)
- getPaddingLeft()
- getPaddingRight();
return (boxWidth - textWidth) * (1 + mTextPanX) / 2.f;
Expand All @@ -337,7 +337,7 @@ private float getVerticalOffset() {

Paint.FontMetrics fm = mPaint.getFontMetrics();

float boxHeight = ((Float.isNaN(mFloatHeight)) ? getMeasuredHeight() : mFloatHeight)
float boxHeight = (Float.isNaN(mFloatHeight) ? getMeasuredHeight() : mFloatHeight)
- getPaddingTop()
- getPaddingBottom();

Expand Down Expand Up @@ -429,9 +429,9 @@ public void layout(int l, int t, int r, int b) {
float vh = mFloatHeight - mPaddingBottom - mPaddingTop;
if (normalScale) {
if (tw * vh > th * vw) { // width limited tw/vw > th/vh
mPaint.setTextSize((mPaintTextSize * vw) / (tw));
mPaint.setTextSize(mPaintTextSize * vw / (tw));
} else { // height limited
mPaint.setTextSize((mPaintTextSize * vh) / (th));
mPaint.setTextSize(mPaintTextSize * vh / (th));
}
} else {
scaleText = (tw * vh > th * vw) ? vw / (float) tw : vh / (float) th;
Expand Down Expand Up @@ -475,9 +475,9 @@ public void layout(float l, float t, float r, float b) {
float vw = r - l - mPaddingRight - mPaddingLeft;
float vh = b - t - mPaddingBottom - mPaddingTop;
if (tw * vh > th * vw) { // width limited tw/vw > th/vh
mPaint.setTextSize((mPaintTextSize * vw) / (tw));
mPaint.setTextSize(mPaintTextSize * vw / (tw));
} else { // height limited
mPaint.setTextSize((mPaintTextSize * vh) / (th));
mPaint.setTextSize(mPaintTextSize * vh / (th));
}
if (mUseOutline || !Float.isNaN(mBaseTextSize)) {
buildShape(Float.isNaN(mBaseTextSize) ? 1.0f : mTextSize / mBaseTextSize);
Expand Down Expand Up @@ -646,7 +646,7 @@ public Typeface getTypeface() {
return mPaint.getTypeface();
}

// @Override
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
Expand Down Expand Up @@ -946,16 +946,16 @@ public void setTextBackgroundRotate(float rotation) {
}

private void updateShaderMatrix() {
float panX = (Float.isNaN(mBackgroundPanX)) ? 0 : mBackgroundPanX;
float panY = (Float.isNaN(mBackgroundPanY)) ? 0 : mBackgroundPanY;
float zoom = (Float.isNaN(mZoom)) ? 1 : mZoom;
float rota = (Float.isNaN(mRotate)) ? 0 : mRotate;
float panX = Float.isNaN(mBackgroundPanX) ? 0 : mBackgroundPanX;
float panY = Float.isNaN(mBackgroundPanY) ? 0 : mBackgroundPanY;
float zoom = Float.isNaN(mZoom) ? 1 : mZoom;
float rota = Float.isNaN(mRotate) ? 0 : mRotate;

mTextShaderMatrix.reset();
float iw = mTextBackgroundBitmap.getWidth();
float ih = mTextBackgroundBitmap.getHeight();
float sw = (Float.isNaN(mTextureWidth)) ? mFloatWidth : mTextureWidth;
float sh = (Float.isNaN(mTextureHeight)) ? mFloatHeight : mTextureHeight;
float sw = Float.isNaN(mTextureWidth) ? mFloatWidth : mTextureWidth;
float sh = Float.isNaN(mTextureHeight) ? mFloatHeight : mTextureHeight;

float scale = zoom * ((iw * sh < ih * sw) ? sw / iw : sh / ih);
mTextShaderMatrix.postScale(scale, scale);
Expand All @@ -967,8 +967,8 @@ private void updateShaderMatrix() {
if (!Float.isNaN(mTextureWidth)) {
gapx = mTextureWidth / 2;
}
float tx = 0.5f * (panX * (gapx) + sw - (scale * iw));
float ty = 0.5f * (panY * (gapy) + sh - (scale * ih));
float tx = 0.5f * (panX * gapx + sw - (scale * iw));
float ty = 0.5f * (panY * gapy + sh - (scale * ih));

mTextShaderMatrix.postTranslate(tx, ty);
mTextShaderMatrix.postRotate(rota, sw / 2, sh / 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public class ArrayLinkedVariables implements ArrayRow.ArrayRowVariables {
* @param variable the variable to add in the list
* @param value the value of the variable
*/
@Override
public final void put(SolverVariable variable, float value) {
if (value == 0) {
remove(variable, true);
Expand Down Expand Up @@ -232,6 +233,7 @@ public final void put(SolverVariable variable, float value) {
* @param variable the variable we want to add
* @param value its value
*/
@Override
public void add(SolverVariable variable, float value, boolean removeFromDefinition) {
if (value > -sEpsilon && value < sEpsilon) {
return;
Expand Down Expand Up @@ -375,6 +377,7 @@ public float use(ArrayRow definition, boolean removeFromDefinition) {
* @param variable the variable we want to remove
* @return the value of the removed variable
*/
@Override
public final float remove(SolverVariable variable, boolean removeFromDefinition) {
if (mCandidate == variable) {
mCandidate = null;
Expand Down Expand Up @@ -416,6 +419,7 @@ public final float remove(SolverVariable variable, boolean removeFromDefinition)
/**
* Clear the list of variables
*/
@Override
public final void clear() {
int current = mHead;
int counter = 0;
Expand All @@ -440,6 +444,7 @@ public final void clear() {
* @param variable the variable we are looking for
* @return return true if we found the variable
*/
@Override
public boolean contains(SolverVariable variable) {
if (mHead == NONE) {
return false;
Expand Down Expand Up @@ -495,6 +500,7 @@ boolean hasAtLeastOnePositiveVariable() {
/**
* Invert the values of all the variables in the list
*/
@Override
public void invert() {
int current = mHead;
int counter = 0;
Expand All @@ -511,6 +517,7 @@ public void invert() {
*
* @param amount amount to divide by
*/
@Override
public void divideByAmount(float amount) {
int current = mHead;
int counter = 0;
Expand All @@ -525,6 +532,7 @@ public int getHead() {
return mHead;
}

@Override
public int getCurrentSize() {
return mCurrentSize;
}
Expand Down Expand Up @@ -586,6 +594,7 @@ SolverVariable getPivotCandidate() {
* @param index the index of the variable we want to return
* @return the variable found, or null
*/
@Override
public SolverVariable getVariable(int index) {
int current = mHead;
int counter = 0;
Expand All @@ -605,6 +614,7 @@ public SolverVariable getVariable(int index) {
* @param index the index of the variable we want to look up
* @return the value of the found variable, or 0 if not found
*/
@Override
public float getVariableValue(int index) {
int current = mHead;
int counter = 0;
Expand All @@ -624,6 +634,7 @@ public float getVariableValue(int index) {
* @param v the variable we are looking up
* @return the value of the found variable, or 0 if not found
*/
@Override
public final float get(SolverVariable v) {
int current = mHead;
int counter = 0;
Expand All @@ -642,6 +653,7 @@ public final float get(SolverVariable v) {
*
* @return size in bytes
*/
@Override
public int sizeInBytes() {
int size = 0;
size += 3 * (mArrayIndices.length * 4);
Expand All @@ -652,6 +664,7 @@ public int sizeInBytes() {
/**
* print out the variables and their values
*/
@Override
public void display() {
int count = mCurrentSize;
System.out.print("{ ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ boolean hasKeyVariable() {
/**
* @TODO: add description
*/
@Override
public String toString() {
return toReadableString();
}
Expand Down Expand Up @@ -682,6 +683,7 @@ public void updateFromRow(LinearSystem system,
/**
* @TODO: add description
*/
@Override
public void updateFromFinalVariable(LinearSystem system,
SolverVariable variable,
boolean removeFromDefinition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class Metrics {
/**
* @TODO: add description
*/
@Override
public String toString() {
return "\n*** Metrics ***\n"
+ "measures: " + measures + "\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public boolean addChildrenToSolver(LinearSystem system) {
}
} else {
Optimizer.checkMatchParent(this, system, widget);
if (!(widget.addFirst())) {
if (!widget.addFirst()) {
widget.addToSolver(system, optimize);
}
}
Expand Down Expand Up @@ -758,7 +758,7 @@ public void layout() {
&& !(child instanceof Guideline)
&& !(child instanceof Barrier)
&& !(child instanceof VirtualLayout)
&& !(child.isInVirtualLayout())) {
&& !child.isInVirtualLayout()) {
DimensionBehaviour widthBehavior = child.getDimensionBehaviour(HORIZONTAL);
DimensionBehaviour heightBehavior = child.getDimensionBehaviour(VERTICAL);

Expand All @@ -785,7 +785,7 @@ public void layout() {

if (count > 2 && (originalHorizontalDimensionBehaviour == WRAP_CONTENT
|| originalVerticalDimensionBehaviour == WRAP_CONTENT)
&& (Optimizer.enabled(mOptimizationLevel, Optimizer.OPTIMIZATION_GROUPING))) {
&& Optimizer.enabled(mOptimizationLevel, Optimizer.OPTIMIZATION_GROUPING)) {
if (Grouping.simpleSolvingPass(this, getMeasurer())) {
if (originalHorizontalDimensionBehaviour == WRAP_CONTENT) {
if (preW < getWidth() && preW > 0) {
Expand Down Expand Up @@ -1147,6 +1147,7 @@ public void setPass(int pass) {
/**
* @TODO: add description
*/
@Override
public void getSceneString(StringBuilder ret) {

ret.append(stringId + ":{\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,12 @@ public void setFinalValue(int position) {
mResolved = true;
}

@Override
public boolean isResolvedHorizontally() {
return mResolved;
}

@Override
public boolean isResolvedVertically() {
return mResolved;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ boolean supportsWrapComputation() {
/**
* @TODO: add description
*/
@Override
public long getWrapDimension() {
final int count = mWidgets.size();
long wrapDimension = 0;
Expand Down Expand Up @@ -491,6 +492,7 @@ public void update(Dependency dependency) {
/**
* @TODO: add description
*/
@Override
public void applyToWidget() {
for (int i = 0; i < mWidgets.size(); i++) {
WidgetRun run = mWidgets.get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public void resolve(int value) {
/**
* @TODO: add description
*/
@Override
public void update(Dependency node) {
for (DependencyNode target : mTargets) {
if (!target.resolved) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class DimensionDependency extends DependencyNode {
}
}

@Override
public void resolve(int value) {
if (resolved) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ public void update(Dependency dependency) {
/**
* @TODO: add description
*/
@Override
public void applyToWidget() {
if (start.resolved) {
mWidget.setX(start.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ void apply() {
/**
* @TODO: add description
*/
@Override
public void applyToWidget() {
if (start.resolved) {
mWidget.setY(start.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ protected void updateRunEnd(Dependency dependency) {
/**
* @TODO: add description
*/
@Override
public void update(Dependency dependency) {
}

Expand Down