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

Commit 9dfc11d

Browse files
jswong65jafu888
authored andcommitted
Fix error-prone issues part2
1 parent 1c79d64 commit 9dfc11d

File tree

12 files changed

+46
-22
lines changed

12 files changed

+46
-22
lines changed

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/utils/widget/ImageFilterView.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,10 @@ private void setMatrix() {
488488
) {
489489
return;
490490
}
491-
float panX = (Float.isNaN(mPanX)) ? 0 : mPanX;
492-
float panY = (Float.isNaN(mPanY)) ? 0 : mPanY;
493-
float zoom = (Float.isNaN(mZoom)) ? 1 : mZoom;
494-
float rota = (Float.isNaN(mRotate)) ? 0 : mRotate;
491+
float panX = Float.isNaN(mPanX) ? 0 : mPanX;
492+
float panY = Float.isNaN(mPanY) ? 0 : mPanY;
493+
float zoom = Float.isNaN(mZoom) ? 1 : mZoom;
494+
float rota = Float.isNaN(mRotate) ? 0 : mRotate;
495495
Matrix imageMatrix = new Matrix();
496496
imageMatrix.reset();
497497
float iw = getDrawable().getIntrinsicWidth();
@@ -666,7 +666,7 @@ public void setCrossfade(float crossfade) {
666666
if (!mOverlay) {
667667
mLayer.getDrawable(0).setAlpha((int) (255 * (1 - mCrossfade)));
668668
}
669-
mLayer.getDrawable(1).setAlpha((int) (255 * (mCrossfade)));
669+
mLayer.getDrawable(1).setAlpha((int) (255 * mCrossfade));
670670
super.setImageDrawable(mLayer);
671671
}
672672
}

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/utils/widget/MotionLabel.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,14 @@ private void setupTexture() {
231231
if (iw <= 0) {
232232
int w = getWidth();
233233
if (w == 0) {
234-
w = ((Float.isNaN(mTextureWidth)) ? 128 : (int) mTextureWidth);
234+
w = (Float.isNaN(mTextureWidth) ? 128 : (int) mTextureWidth);
235235
}
236236
iw = w;
237237
}
238238
if (ih <= 0) {
239239
int h = getHeight();
240240
if (h == 0) {
241-
h = ((Float.isNaN(mTextureHeight)) ? 128 : (int) mTextureHeight);
241+
h = (Float.isNaN(mTextureHeight) ? 128 : (int) mTextureHeight);
242242
}
243243
ih = h;
244244
}
@@ -326,7 +326,7 @@ private float getHorizontalOffset() {
326326
float scale = Float.isNaN(mBaseTextSize) ? 1.0f : mTextSize / mBaseTextSize;
327327

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

338338
Paint.FontMetrics fm = mPaint.getFontMetrics();
339339

340-
float boxHeight = ((Float.isNaN(mFloatHeight)) ? getMeasuredHeight() : mFloatHeight)
340+
float boxHeight = (Float.isNaN(mFloatHeight) ? getMeasuredHeight() : mFloatHeight)
341341
- getPaddingTop()
342342
- getPaddingBottom();
343343

@@ -429,9 +429,9 @@ public void layout(int l, int t, int r, int b) {
429429
float vh = mFloatHeight - mPaddingBottom - mPaddingTop;
430430
if (normalScale) {
431431
if (tw * vh > th * vw) { // width limited tw/vw > th/vh
432-
mPaint.setTextSize((mPaintTextSize * vw) / (tw));
432+
mPaint.setTextSize(mPaintTextSize * vw / (tw));
433433
} else { // height limited
434-
mPaint.setTextSize((mPaintTextSize * vh) / (th));
434+
mPaint.setTextSize(mPaintTextSize * vh / (th));
435435
}
436436
} else {
437437
scaleText = (tw * vh > th * vw) ? vw / (float) tw : vh / (float) th;
@@ -475,9 +475,9 @@ public void layout(float l, float t, float r, float b) {
475475
float vw = r - l - mPaddingRight - mPaddingLeft;
476476
float vh = b - t - mPaddingBottom - mPaddingTop;
477477
if (tw * vh > th * vw) { // width limited tw/vw > th/vh
478-
mPaint.setTextSize((mPaintTextSize * vw) / (tw));
478+
mPaint.setTextSize(mPaintTextSize * vw / (tw));
479479
} else { // height limited
480-
mPaint.setTextSize((mPaintTextSize * vh) / (th));
480+
mPaint.setTextSize(mPaintTextSize * vh / (th));
481481
}
482482
if (mUseOutline || !Float.isNaN(mBaseTextSize)) {
483483
buildShape(Float.isNaN(mBaseTextSize) ? 1.0f : mTextSize / mBaseTextSize);
@@ -646,7 +646,7 @@ public Typeface getTypeface() {
646646
return mPaint.getTypeface();
647647
}
648648

649-
// @Override
649+
@Override
650650
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
651651
int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
652652
int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
@@ -946,16 +946,16 @@ public void setTextBackgroundRotate(float rotation) {
946946
}
947947

948948
private void updateShaderMatrix() {
949-
float panX = (Float.isNaN(mBackgroundPanX)) ? 0 : mBackgroundPanX;
950-
float panY = (Float.isNaN(mBackgroundPanY)) ? 0 : mBackgroundPanY;
951-
float zoom = (Float.isNaN(mZoom)) ? 1 : mZoom;
952-
float rota = (Float.isNaN(mRotate)) ? 0 : mRotate;
949+
float panX = Float.isNaN(mBackgroundPanX) ? 0 : mBackgroundPanX;
950+
float panY = Float.isNaN(mBackgroundPanY) ? 0 : mBackgroundPanY;
951+
float zoom = Float.isNaN(mZoom) ? 1 : mZoom;
952+
float rota = Float.isNaN(mRotate) ? 0 : mRotate;
953953

954954
mTextShaderMatrix.reset();
955955
float iw = mTextBackgroundBitmap.getWidth();
956956
float ih = mTextBackgroundBitmap.getHeight();
957-
float sw = (Float.isNaN(mTextureWidth)) ? mFloatWidth : mTextureWidth;
958-
float sh = (Float.isNaN(mTextureHeight)) ? mFloatHeight : mTextureHeight;
957+
float sw = Float.isNaN(mTextureWidth) ? mFloatWidth : mTextureWidth;
958+
float sh = Float.isNaN(mTextureHeight) ? mFloatHeight : mTextureHeight;
959959

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

973973
mTextShaderMatrix.postTranslate(tx, ty);
974974
mTextShaderMatrix.postRotate(rota, sw / 2, sh / 2);

constraintlayout/core/src/main/java/androidx/constraintlayout/core/ArrayLinkedVariables.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public class ArrayLinkedVariables implements ArrayRow.ArrayRowVariables {
123123
* @param variable the variable to add in the list
124124
* @param value the value of the variable
125125
*/
126+
@Override
126127
public final void put(SolverVariable variable, float value) {
127128
if (value == 0) {
128129
remove(variable, true);
@@ -232,6 +233,7 @@ public final void put(SolverVariable variable, float value) {
232233
* @param variable the variable we want to add
233234
* @param value its value
234235
*/
236+
@Override
235237
public void add(SolverVariable variable, float value, boolean removeFromDefinition) {
236238
if (value > -sEpsilon && value < sEpsilon) {
237239
return;
@@ -375,6 +377,7 @@ public float use(ArrayRow definition, boolean removeFromDefinition) {
375377
* @param variable the variable we want to remove
376378
* @return the value of the removed variable
377379
*/
380+
@Override
378381
public final float remove(SolverVariable variable, boolean removeFromDefinition) {
379382
if (mCandidate == variable) {
380383
mCandidate = null;
@@ -416,6 +419,7 @@ public final float remove(SolverVariable variable, boolean removeFromDefinition)
416419
/**
417420
* Clear the list of variables
418421
*/
422+
@Override
419423
public final void clear() {
420424
int current = mHead;
421425
int counter = 0;
@@ -440,6 +444,7 @@ public final void clear() {
440444
* @param variable the variable we are looking for
441445
* @return return true if we found the variable
442446
*/
447+
@Override
443448
public boolean contains(SolverVariable variable) {
444449
if (mHead == NONE) {
445450
return false;
@@ -495,6 +500,7 @@ boolean hasAtLeastOnePositiveVariable() {
495500
/**
496501
* Invert the values of all the variables in the list
497502
*/
503+
@Override
498504
public void invert() {
499505
int current = mHead;
500506
int counter = 0;
@@ -511,6 +517,7 @@ public void invert() {
511517
*
512518
* @param amount amount to divide by
513519
*/
520+
@Override
514521
public void divideByAmount(float amount) {
515522
int current = mHead;
516523
int counter = 0;
@@ -525,6 +532,7 @@ public int getHead() {
525532
return mHead;
526533
}
527534

535+
@Override
528536
public int getCurrentSize() {
529537
return mCurrentSize;
530538
}
@@ -586,6 +594,7 @@ SolverVariable getPivotCandidate() {
586594
* @param index the index of the variable we want to return
587595
* @return the variable found, or null
588596
*/
597+
@Override
589598
public SolverVariable getVariable(int index) {
590599
int current = mHead;
591600
int counter = 0;
@@ -605,6 +614,7 @@ public SolverVariable getVariable(int index) {
605614
* @param index the index of the variable we want to look up
606615
* @return the value of the found variable, or 0 if not found
607616
*/
617+
@Override
608618
public float getVariableValue(int index) {
609619
int current = mHead;
610620
int counter = 0;
@@ -624,6 +634,7 @@ public float getVariableValue(int index) {
624634
* @param v the variable we are looking up
625635
* @return the value of the found variable, or 0 if not found
626636
*/
637+
@Override
627638
public final float get(SolverVariable v) {
628639
int current = mHead;
629640
int counter = 0;
@@ -642,6 +653,7 @@ public final float get(SolverVariable v) {
642653
*
643654
* @return size in bytes
644655
*/
656+
@Override
645657
public int sizeInBytes() {
646658
int size = 0;
647659
size += 3 * (mArrayIndices.length * 4);
@@ -652,6 +664,7 @@ public int sizeInBytes() {
652664
/**
653665
* print out the variables and their values
654666
*/
667+
@Override
655668
public void display() {
656669
int count = mCurrentSize;
657670
System.out.print("{ ");

constraintlayout/core/src/main/java/androidx/constraintlayout/core/ArrayRow.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ boolean hasKeyVariable() {
135135
/**
136136
* @TODO: add description
137137
*/
138+
@Override
138139
public String toString() {
139140
return toReadableString();
140141
}
@@ -682,6 +683,7 @@ public void updateFromRow(LinearSystem system,
682683
/**
683684
* @TODO: add description
684685
*/
686+
@Override
685687
public void updateFromFinalVariable(LinearSystem system,
686688
SolverVariable variable,
687689
boolean removeFromDefinition) {

constraintlayout/core/src/main/java/androidx/constraintlayout/core/Metrics.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class Metrics {
6868
/**
6969
* @TODO: add description
7070
*/
71+
@Override
7172
public String toString() {
7273
return "\n*** Metrics ***\n"
7374
+ "measures: " + measures + "\n"

constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/ConstraintWidgetContainer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,7 @@ public void setPass(int pass) {
11471147
/**
11481148
* @TODO: add description
11491149
*/
1150+
@Override
11501151
public void getSceneString(StringBuilder ret) {
11511152

11521153
ret.append(stringId + ":{\n");

constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/analyzer/ChainRun.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ boolean supportsWrapComputation() {
6565
/**
6666
* @TODO: add description
6767
*/
68+
@Override
6869
public long getWrapDimension() {
6970
final int count = mWidgets.size();
7071
long wrapDimension = 0;
@@ -491,6 +492,7 @@ public void update(Dependency dependency) {
491492
/**
492493
* @TODO: add description
493494
*/
495+
@Override
494496
public void applyToWidget() {
495497
for (int i = 0; i < mWidgets.size(); i++) {
496498
WidgetRun run = mWidgets.get(i);

constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/analyzer/DependencyNode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public void resolve(int value) {
6969
/**
7070
* @TODO: add description
7171
*/
72+
@Override
7273
public void update(Dependency node) {
7374
for (DependencyNode target : mTargets) {
7475
if (!target.resolved) {

constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/analyzer/DimensionDependency.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class DimensionDependency extends DependencyNode {
2929
}
3030
}
3131

32+
@Override
3233
public void resolve(int value) {
3334
if (resolved) {
3435
return;

constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/analyzer/HorizontalWidgetRun.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ public void update(Dependency dependency) {
609609
/**
610610
* @TODO: add description
611611
*/
612+
@Override
612613
public void applyToWidget() {
613614
if (start.resolved) {
614615
mWidget.setX(start.value);

constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/analyzer/VerticalWidgetRun.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ void apply() {
478478
/**
479479
* @TODO: add description
480480
*/
481+
@Override
481482
public void applyToWidget() {
482483
if (start.resolved) {
483484
mWidget.setY(start.value);

constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/analyzer/WidgetRun.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ protected void updateRunEnd(Dependency dependency) {
260260
/**
261261
* @TODO: add description
262262
*/
263+
@Override
263264
public void update(Dependency dependency) {
264265
}
265266

0 commit comments

Comments
 (0)