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

Fix error-prone issues part1 #630

Merged
merged 2 commits into from
Jun 24, 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 @@ -29,7 +29,7 @@

public class CustomSupport {
private static final String TAG = "CustomSupport";

private static final boolean DEBUG = false;
/**
* sets the interpolated value
* @param att
Expand Down Expand Up @@ -83,6 +83,10 @@ public static void setInterpolatedValue(ConstraintAttribute att, View view, floa
method = viewClass.getMethod(methodName, Float.TYPE);
method.invoke(view, value[0]);
break;
default:
if (DEBUG) {
Log.v(TAG, att.getType().toString());
}
}
} catch (NoSuchMethodException e) {
Log.e(TAG, "no method " + methodName + " on View \"" + Debug.getName(view) + "\"");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ static class CustomSet extends ViewOscillator {
float[] mValue = new float[1];
protected ConstraintAttribute mCustom;

@Override
protected void setCustom(Object custom) {
mCustom = (ConstraintAttribute) custom;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public void setup(int curveType) {
* @param position the position
* @param value the value
*/
@Override
public void setPoint(int position, float value) {
throw new RuntimeException("call of custom attribute setPoint");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public CustomSet(String attribute, SparseArray<ConstraintAttribute> attrList) {
* Setup the curve
* @param curveType
*/
@Override
public void setup(int curveType) {
int size = mConstraintAttributeList.size();
int dimensionality =
Expand Down Expand Up @@ -303,6 +304,7 @@ public void setup(int curveType) {
* @param shape
* @param offset
*/
@Override
public void setPoint(int position, float value, float period, int shape, float offset) {
throw new RuntimeException("Wrong call for custom attribute");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public Key copy(Key src) {
* Return a copy of this
* @return
*/
@Override
public abstract Key clone();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public void getAttributeNames(HashSet<String> attributes) {
* create the interpolations associated with this KeyAttribute
* @param interpolation will be added to with keyAttributes
*/
@Override
public void setInterpolation(HashMap<String, Integer> interpolation) {
if (mCurveFit == -1) {
return;
Expand Down Expand Up @@ -472,6 +473,7 @@ public static void read(KeyAttributes c, TypedArray a) {
* @param src to be copied
* @return self
*/
@Override
public Key copy(Key src) {
super.copy(src);
KeyAttributes k = (KeyAttributes) src;
Expand Down Expand Up @@ -499,6 +501,7 @@ public Key copy(Key src) {
* Clone this KeyAttributes
* @return
*/
@Override
public Key clone() {
return new KeyAttributes().copy(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public class KeyCycle extends Key {
* @param context
* @param attrs
*/
@Override
public void load(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.KeyCycle);
Loader.read(this, a);
Expand Down Expand Up @@ -491,6 +492,7 @@ public void setValue(String tag, Object value) {
* @param src to be copied
* @return self
*/
@Override
public Key copy(Key src) {
super.copy(src);
KeyCycle k = (KeyCycle) src;
Expand Down Expand Up @@ -521,6 +523,7 @@ public Key copy(Key src) {
* Clone this KeyAttributes
* @return
*/
@Override
public Key clone() {
return new KeyCycle().copy(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public void getAttributeNames(HashSet<String> attributes) {
*
* @param interpolation
*/
@Override
public void setInterpolation(HashMap<String, Integer> interpolation) {
if (mCurveFit == -1) {
return;
Expand Down Expand Up @@ -357,6 +358,7 @@ public void setValue(String tag, Object value) {
* @param src to be copied
* @return self
*/
@Override
public Key copy(Key src) {
super.copy(src);
KeyTimeCycle k = (KeyTimeCycle) src;
Expand Down Expand Up @@ -386,6 +388,7 @@ public Key copy(Key src) {
*
* @return
*/
@Override
public Key clone() {
return new KeyTimeCycle().copy(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public abstract class MotionInterpolator implements Interpolator {
* @param v
* @return
*/
@Override
public abstract float getInterpolation(float v);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ protected void setTransition(MotionScene.Transition transition) {
mTransitionGoalPosition = 0;
}
mTransitionLastTime =
(transition.isTransitionFlag(TRANSITION_FLAG_FIRST_DRAW)) ? -1 : getNanoTime();
transition.isTransitionFlag(TRANSITION_FLAG_FIRST_DRAW) ? -1 : getNanoTime();
if (DEBUG) {
Log.v(TAG, Debug.getLocation() + " new mTransitionLastPosition = "
+ mTransitionLastPosition + "");
Expand Down Expand Up @@ -1910,7 +1910,7 @@ private void setupMotionViews() {
}
float x = f.getFinalX();
float y = f.getFinalY();
float mdist = (flip) ? (y - x) : (y + x);
float mdist = flip ? (y - x) : (y + x);
min = Math.min(min, mdist);
max = Math.max(max, mdist);
}
Expand Down Expand Up @@ -1944,9 +1944,9 @@ private void setupMotionViews() {
MotionController f = mFrameArrayList.get(getChildAt(i));
float x = f.getFinalX();
float y = f.getFinalY();
float mdist = (flip) ? (y - x) : (y + x);
float mdist = flip ? (y - x) : (y + x);
f.mStaggerScale = 1 / (1 - stagger);
f.mStaggerOffset = stagger - stagger * (mdist - (min)) / (max - (min));
f.mStaggerOffset = stagger - stagger * (mdist - min) / (max - min);
}
}
}
Expand Down Expand Up @@ -2519,7 +2519,7 @@ public void transitionToState(int id, int screenWidth, int screenHeight, int dur
float x = f.getFinalX();
float y = f.getFinalY();
f.mStaggerScale = 1 / (1 - stagger);
f.mStaggerOffset = stagger - stagger * (x + y - (min)) / (max - (min));
f.mStaggerOffset = stagger - stagger * (x + y - min) / (max - min);
}
}

Expand Down Expand Up @@ -2723,8 +2723,8 @@ private void setupConstraintWidget(ConstraintWidgetContainer base, ConstraintSet
if (view instanceof Barrier) {
((Barrier) view).validateParams();
if (DEBUG) {
Log.v(TAG, ">>>>>>>>>> Barrier " + (Debug.getName(getContext(),
((Barrier) view).getReferencedIds())));
Log.v(TAG, ">>>>>>>>>> Barrier " + Debug.getName(getContext(),
((Barrier) view).getReferencedIds()));
}
}
}
Expand Down Expand Up @@ -3001,7 +3001,7 @@ private Rect toRect(ConstraintWidget cw) {

@Override
public void requestLayout() {
if (!(mMeasureDuringTransition)) {
if (!mMeasureDuringTransition) {
if (mCurrentState == UNSET && mScene != null
&& mScene.mCurrentTransition != null) {
int mode = mScene.mCurrentTransition.getLayoutDuringTransition();
Expand Down Expand Up @@ -3779,8 +3779,8 @@ void evaluate(boolean force) {
}

boolean newState = false;
if (mKeepAnimating || mInTransition
&& (force || mTransitionGoalPosition != mTransitionLastPosition)) {
if (mKeepAnimating || (mInTransition
&& (force || mTransitionGoalPosition != mTransitionLastPosition))) {
float dir = Math.signum(mTransitionGoalPosition - mTransitionLastPosition);
long currentTime = getNanoTime();

Expand Down Expand Up @@ -3818,7 +3818,7 @@ void evaluate(boolean force) {
position = mInterpolator.getInterpolation(time);
if (mInterpolator == mStopLogic) {
boolean dp = mStopLogic.isStopped();
stopLogicDone = (dp) ? stopLogicStop : stopLogicContinue;
stopLogicDone = dp ? stopLogicStop : stopLogicContinue;
}

if (DEBUG) {
Expand Down Expand Up @@ -4037,10 +4037,10 @@ private void init(AttributeSet attrs) {
apply = a.getBoolean(attr, apply);
} else if (attr == R.styleable.MotionLayout_showPaths) {
if (mDebugPath == 0) { // favor motionDebug
mDebugPath = (a.getBoolean(attr, false)) ? DEBUG_SHOW_PATH : 0;
mDebugPath = a.getBoolean(attr, false) ? DEBUG_SHOW_PATH : 0;
}
} else if (attr == R.styleable.MotionLayout_motionDebug) {
mDebugPath = (a.getInt(attr, 0));
mDebugPath = a.getInt(attr, 0);
}
}
a.recycle();
Expand Down Expand Up @@ -4281,7 +4281,7 @@ public boolean onInterceptTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
RectF region = touchResponse.getTouchRegion(this, new RectF());
if (region != null
&& (!region.contains(event.getX(), event.getY()))) {
&& !region.contains(event.getX(), event.getY())) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,12 @@ public Transition bestTransitionFor(int currentState,
transition.mTouchResponse.setRTL(mRtl);
RectF region = transition.mTouchResponse.getTouchRegion(mMotionLayout, cache);
if (region != null && lastTouchDown != null
&& (!region.contains(lastTouchDown.getX(), lastTouchDown.getY()))) {
&& !region.contains(lastTouchDown.getX(), lastTouchDown.getY())) {
continue;
}
region = transition.mTouchResponse.getLimitBoundsTo(mMotionLayout, cache);
if (region != null && lastTouchDown != null
&& (!region.contains(lastTouchDown.getX(), lastTouchDown.getY()))) {
&& !region.contains(lastTouchDown.getX(), lastTouchDown.getY())) {
continue;
}

Expand Down Expand Up @@ -1708,8 +1708,8 @@ void processTouchEvent(MotionEvent event, int currentState, MotionLayout motionL
region = mCurrentTransition.mTouchResponse
.getTouchRegion(mMotionLayout, cache);
if (region != null
&& (!region.contains(mLastTouchDown.getX(),
mLastTouchDown.getY()))) {
&& !region.contains(mLastTouchDown.getX(),
mLastTouchDown.getY())) {
mMotionOutsideRegion = true;
} else {
mMotionOutsideRegion = false;
Expand All @@ -1729,7 +1729,7 @@ void processTouchEvent(MotionEvent event, int currentState, MotionLayout motionL
if (DEBUG) {
Log.v(TAG, "----- ACTION_MOVE " + dx + "," + dy);
}
if (dx == 0.0 && dy == 0.0 || mLastTouchDown == null) {
if ((dx == 0.0 && dy == 0.0) || mLastTouchDown == null) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
*/
public class ConstraintAttribute {
private static final String TAG = "TransitionLayout";
private static final boolean DEBUG = false;
private boolean mMethod = false;
String mName;
private AttributeType mType;
Expand Down Expand Up @@ -179,7 +180,7 @@ public void getValuesToInterpolate(float[] ret) {
int a = 0xFF & (mColorValue >> 24);
int r = 0xFF & (mColorValue >> 16);
int g = 0xFF & (mColorValue >> 8);
int b = 0xFF & (mColorValue);
int b = 0xFF & mColorValue;
float f_r = (float) Math.pow(r / 255.0f, 2.2);
float f_g = (float) Math.pow(g / 255.0f, 2.2);
float f_b = (float) Math.pow(b / 255.0f, 2.2);
Expand All @@ -196,6 +197,10 @@ public void getValuesToInterpolate(float[] ret) {
case DIMENSION_TYPE:
ret[0] = mFloatValue;
break;
default:
if (DEBUG) {
Log.v(TAG, mType.toString());
}
}
}

Expand Down Expand Up @@ -224,6 +229,10 @@ public void setValue(float[] value) {
break;
case DIMENSION_TYPE:
mFloatValue = value[0];
default:
if (DEBUG) {
Log.v(TAG, mType.toString());
}

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ public final void measure(ConstraintWidget widget,
== BasicMeasure.Measure.USE_GIVEN_DIMENSIONS
|| !shouldDoWrap
|| (shouldDoWrap && otherDimensionStable)
|| (child instanceof Placeholder)
|| child instanceof Placeholder
|| widget.isResolvedHorizontally();
if (useCurrent) {
horizontalSpec = MeasureSpec.makeMeasureSpec(widget.getWidth(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2275,6 +2275,7 @@ private void setColorValue(String attributeName, int value) {
* Return a copy of the Constraint
* @return
*/
@Override
public Constraint clone() {
Constraint clone = new Constraint();
clone.layout.copyFrom(layout);
Expand Down Expand Up @@ -6148,10 +6149,10 @@ String lookup(int id) {
if (id != -1) {
return mContext.getResources().getResourceEntryName(id);
} else {
return "unknown" + (++mUnknownCount);
return "unknown" + ++mUnknownCount;
}
} catch (Exception ex) {
return "unknown" + (++mUnknownCount);
return "unknown" + ++mUnknownCount;
}
}

Expand Down Expand Up @@ -6404,10 +6405,10 @@ String lookup(int id) {
if (id != -1) {
return mContext.getResources().getResourceEntryName(id);
} else {
return "unknown" + (++mUnknownCount);
return "unknown" + ++mUnknownCount;
}
} catch (Exception ex) {
return "unknown" + (++mUnknownCount);
return "unknown" + ++mUnknownCount;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void getValuesToInterpolate(float[] ret) {
int a = 0xFF & (mColorValue >> 24);
int r = 0xFF & (mColorValue >> 16);
int g = 0xFF & (mColorValue >> 8);
int b = 0xFF & (mColorValue);
int b = 0xFF & mColorValue;
float f_r = (float) Math.pow(r / 255.0f, 2.2);
float f_g = (float) Math.pow(g / 255.0f, 2.2);
float f_b = (float) Math.pow(b / 255.0f, 2.2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void getValuesToInterpolate(float[] ret) {
int a = 0xFF & (mIntegerValue >> 24);
int r = 0xFF & (mIntegerValue >> 16);
int g = 0xFF & (mIntegerValue >> 8);
int b = 0xFF & (mIntegerValue);
int b = 0xFF & mIntegerValue;
float f_r = (float) Math.pow(r / 255.0f, 2.2);
float f_g = (float) Math.pow(g / 255.0f, 2.2);
float f_b = (float) Math.pow(b / 255.0f, 2.2);
Expand Down
Loading