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

Commit 8bc84e4

Browse files
authored
Merge pull request #630 from jswong65/fix-errorprone
Fix error-prone issues part1
2 parents 9d88195 + afd155a commit 8bc84e4

27 files changed

+89
-121
lines changed

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/CustomSupport.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
public class CustomSupport {
3131
private static final String TAG = "CustomSupport";
32-
32+
private static final boolean DEBUG = false;
3333
/**
3434
* sets the interpolated value
3535
* @param att
@@ -83,6 +83,10 @@ public static void setInterpolatedValue(ConstraintAttribute att, View view, floa
8383
method = viewClass.getMethod(methodName, Float.TYPE);
8484
method.invoke(view, value[0]);
8585
break;
86+
default:
87+
if (DEBUG) {
88+
Log.v(TAG, att.getType().toString());
89+
}
8690
}
8791
} catch (NoSuchMethodException e) {
8892
Log.e(TAG, "no method " + methodName + " on View \"" + Debug.getName(view) + "\"");

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewOscillator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ static class CustomSet extends ViewOscillator {
181181
float[] mValue = new float[1];
182182
protected ConstraintAttribute mCustom;
183183

184+
@Override
184185
protected void setCustom(Object custom) {
185186
mCustom = (ConstraintAttribute) custom;
186187
}

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewSpline.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ public void setup(int curveType) {
242242
* @param position the position
243243
* @param value the value
244244
*/
245+
@Override
245246
public void setPoint(int position, float value) {
246247
throw new RuntimeException("call of custom attribute setPoint");
247248
}

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewTimeCycle.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ public CustomSet(String attribute, SparseArray<ConstraintAttribute> attrList) {
272272
* Setup the curve
273273
* @param curveType
274274
*/
275+
@Override
275276
public void setup(int curveType) {
276277
int size = mConstraintAttributeList.size();
277278
int dimensionality =
@@ -303,6 +304,7 @@ public void setup(int curveType) {
303304
* @param shape
304305
* @param offset
305306
*/
307+
@Override
306308
public void setPoint(int position, float value, float period, int shape, float offset) {
307309
throw new RuntimeException("Wrong call for custom attribute");
308310
}

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/Key.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ public Key copy(Key src) {
154154
* Return a copy of this
155155
* @return
156156
*/
157+
@Override
157158
public abstract Key clone();
158159

159160
/**

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyAttributes.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public void getAttributeNames(HashSet<String> attributes) {
138138
* create the interpolations associated with this KeyAttribute
139139
* @param interpolation will be added to with keyAttributes
140140
*/
141+
@Override
141142
public void setInterpolation(HashMap<String, Integer> interpolation) {
142143
if (mCurveFit == -1) {
143144
return;
@@ -472,6 +473,7 @@ public static void read(KeyAttributes c, TypedArray a) {
472473
* @param src to be copied
473474
* @return self
474475
*/
476+
@Override
475477
public Key copy(Key src) {
476478
super.copy(src);
477479
KeyAttributes k = (KeyAttributes) src;
@@ -499,6 +501,7 @@ public Key copy(Key src) {
499501
* Clone this KeyAttributes
500502
* @return
501503
*/
504+
@Override
502505
public Key clone() {
503506
return new KeyAttributes().copy(this);
504507
}

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyCycle.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public class KeyCycle extends Key {
8585
* @param context
8686
* @param attrs
8787
*/
88+
@Override
8889
public void load(Context context, AttributeSet attrs) {
8990
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.KeyCycle);
9091
Loader.read(this, a);
@@ -491,6 +492,7 @@ public void setValue(String tag, Object value) {
491492
* @param src to be copied
492493
* @return self
493494
*/
495+
@Override
494496
public Key copy(Key src) {
495497
super.copy(src);
496498
KeyCycle k = (KeyCycle) src;
@@ -521,6 +523,7 @@ public Key copy(Key src) {
521523
* Clone this KeyAttributes
522524
* @return
523525
*/
526+
@Override
524527
public Key clone() {
525528
return new KeyCycle().copy(this);
526529
}

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyTimeCycle.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ public void getAttributeNames(HashSet<String> attributes) {
136136
*
137137
* @param interpolation
138138
*/
139+
@Override
139140
public void setInterpolation(HashMap<String, Integer> interpolation) {
140141
if (mCurveFit == -1) {
141142
return;
@@ -357,6 +358,7 @@ public void setValue(String tag, Object value) {
357358
* @param src to be copied
358359
* @return self
359360
*/
361+
@Override
360362
public Key copy(Key src) {
361363
super.copy(src);
362364
KeyTimeCycle k = (KeyTimeCycle) src;
@@ -386,6 +388,7 @@ public Key copy(Key src) {
386388
*
387389
* @return
388390
*/
391+
@Override
389392
public Key clone() {
390393
return new KeyTimeCycle().copy(this);
391394
}

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionInterpolator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public abstract class MotionInterpolator implements Interpolator {
2828
* @param v
2929
* @return
3030
*/
31+
@Override
3132
public abstract float getInterpolation(float v);
3233

3334
/**

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionLayout.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ protected void setTransition(MotionScene.Transition transition) {
14731473
mTransitionGoalPosition = 0;
14741474
}
14751475
mTransitionLastTime =
1476-
(transition.isTransitionFlag(TRANSITION_FLAG_FIRST_DRAW)) ? -1 : getNanoTime();
1476+
transition.isTransitionFlag(TRANSITION_FLAG_FIRST_DRAW) ? -1 : getNanoTime();
14771477
if (DEBUG) {
14781478
Log.v(TAG, Debug.getLocation() + " new mTransitionLastPosition = "
14791479
+ mTransitionLastPosition + "");
@@ -1910,7 +1910,7 @@ private void setupMotionViews() {
19101910
}
19111911
float x = f.getFinalX();
19121912
float y = f.getFinalY();
1913-
float mdist = (flip) ? (y - x) : (y + x);
1913+
float mdist = flip ? (y - x) : (y + x);
19141914
min = Math.min(min, mdist);
19151915
max = Math.max(max, mdist);
19161916
}
@@ -1944,9 +1944,9 @@ private void setupMotionViews() {
19441944
MotionController f = mFrameArrayList.get(getChildAt(i));
19451945
float x = f.getFinalX();
19461946
float y = f.getFinalY();
1947-
float mdist = (flip) ? (y - x) : (y + x);
1947+
float mdist = flip ? (y - x) : (y + x);
19481948
f.mStaggerScale = 1 / (1 - stagger);
1949-
f.mStaggerOffset = stagger - stagger * (mdist - (min)) / (max - (min));
1949+
f.mStaggerOffset = stagger - stagger * (mdist - min) / (max - min);
19501950
}
19511951
}
19521952
}
@@ -2519,7 +2519,7 @@ public void transitionToState(int id, int screenWidth, int screenHeight, int dur
25192519
float x = f.getFinalX();
25202520
float y = f.getFinalY();
25212521
f.mStaggerScale = 1 / (1 - stagger);
2522-
f.mStaggerOffset = stagger - stagger * (x + y - (min)) / (max - (min));
2522+
f.mStaggerOffset = stagger - stagger * (x + y - min) / (max - min);
25232523
}
25242524
}
25252525

@@ -2723,8 +2723,8 @@ private void setupConstraintWidget(ConstraintWidgetContainer base, ConstraintSet
27232723
if (view instanceof Barrier) {
27242724
((Barrier) view).validateParams();
27252725
if (DEBUG) {
2726-
Log.v(TAG, ">>>>>>>>>> Barrier " + (Debug.getName(getContext(),
2727-
((Barrier) view).getReferencedIds())));
2726+
Log.v(TAG, ">>>>>>>>>> Barrier " + Debug.getName(getContext(),
2727+
((Barrier) view).getReferencedIds()));
27282728
}
27292729
}
27302730
}
@@ -3001,7 +3001,7 @@ private Rect toRect(ConstraintWidget cw) {
30013001

30023002
@Override
30033003
public void requestLayout() {
3004-
if (!(mMeasureDuringTransition)) {
3004+
if (!mMeasureDuringTransition) {
30053005
if (mCurrentState == UNSET && mScene != null
30063006
&& mScene.mCurrentTransition != null) {
30073007
int mode = mScene.mCurrentTransition.getLayoutDuringTransition();
@@ -3779,8 +3779,8 @@ void evaluate(boolean force) {
37793779
}
37803780

37813781
boolean newState = false;
3782-
if (mKeepAnimating || mInTransition
3783-
&& (force || mTransitionGoalPosition != mTransitionLastPosition)) {
3782+
if (mKeepAnimating || (mInTransition
3783+
&& (force || mTransitionGoalPosition != mTransitionLastPosition))) {
37843784
float dir = Math.signum(mTransitionGoalPosition - mTransitionLastPosition);
37853785
long currentTime = getNanoTime();
37863786

@@ -3818,7 +3818,7 @@ void evaluate(boolean force) {
38183818
position = mInterpolator.getInterpolation(time);
38193819
if (mInterpolator == mStopLogic) {
38203820
boolean dp = mStopLogic.isStopped();
3821-
stopLogicDone = (dp) ? stopLogicStop : stopLogicContinue;
3821+
stopLogicDone = dp ? stopLogicStop : stopLogicContinue;
38223822
}
38233823

38243824
if (DEBUG) {
@@ -4037,10 +4037,10 @@ private void init(AttributeSet attrs) {
40374037
apply = a.getBoolean(attr, apply);
40384038
} else if (attr == R.styleable.MotionLayout_showPaths) {
40394039
if (mDebugPath == 0) { // favor motionDebug
4040-
mDebugPath = (a.getBoolean(attr, false)) ? DEBUG_SHOW_PATH : 0;
4040+
mDebugPath = a.getBoolean(attr, false) ? DEBUG_SHOW_PATH : 0;
40414041
}
40424042
} else if (attr == R.styleable.MotionLayout_motionDebug) {
4043-
mDebugPath = (a.getInt(attr, 0));
4043+
mDebugPath = a.getInt(attr, 0);
40444044
}
40454045
}
40464046
a.recycle();
@@ -4281,7 +4281,7 @@ public boolean onInterceptTouchEvent(MotionEvent event) {
42814281
if (event.getAction() == MotionEvent.ACTION_DOWN) {
42824282
RectF region = touchResponse.getTouchRegion(this, new RectF());
42834283
if (region != null
4284-
&& (!region.contains(event.getX(), event.getY()))) {
4284+
&& !region.contains(event.getX(), event.getY())) {
42854285
return false;
42864286
}
42874287
}

0 commit comments

Comments
 (0)