Commit 96c7ab01 authored by Rob Buis's avatar Rob Buis Committed by Commit Bot

Fix errorprone NarrowingCompoundAssignment warnings

Fix errorprone NarrowingCompoundAssignment warnings and make
sure it is treated as error after this CL.

http://errorprone.info/bugpattern/NarrowingCompoundAssignment

Bug: 801268

Change-Id: Ief55318e789176288962359566d708af51c7c890
Reviewed-on: https://chromium-review.googlesource.com/953181Reviewed-by: default avatarPeter Wen <wnwen@chromium.org>
Reviewed-by: default avatarJoe Downing <joedow@chromium.org>
Reviewed-by: default avatarJohn Budorick <jbudorick@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Rob Buis <rob.buis@samsung.com>
Cr-Commit-Position: refs/heads/master@{#541888}
parent 0b3140b0
......@@ -23,8 +23,6 @@ import colorama
ERRORPRONE_WARNINGS_TO_TURN_OFF = [
# TODO(crbug.com/801210): Follow steps in bug.
'SynchronizeOnNonFinalField',
# TODO(crbug.com/801268): Follow steps in bug.
'NarrowingCompoundAssignment',
# TODO(crbug.com/802073): Follow steps in bug.
'TypeParameterUnusedInFormals',
# TODO(crbug.com/802075): Follow steps in bug.
......@@ -98,6 +96,7 @@ ERRORPRONE_WARNINGS_TO_ERROR = [
'FloatingPointLiteralPrecision',
'JavaLangClash',
'MissingOverride',
'NarrowingCompoundAssignment',
'ParameterName',
'StaticQualifiedUsingExpression',
'UseCorrectAssertInTests',
......
......@@ -252,8 +252,8 @@ public class StackScroller {
float oldVelocityY = mScrollerY.mCurrVelocity;
if (Math.signum(velocityX) == Math.signum(oldVelocityX)
&& Math.signum(velocityY) == Math.signum(oldVelocityY)) {
velocityX += oldVelocityX;
velocityY += oldVelocityY;
velocityX = (int) (velocityX + oldVelocityX);
velocityY = (int) (velocityY + oldVelocityY);
}
}
......@@ -411,7 +411,7 @@ public class StackScroller {
final float tInf = SPLINE_TIME[index];
final float tSup = SPLINE_TIME[index + 1];
final float timeCoef = tInf + (x - xInf) / (xSup - xInf) * (tSup - tInf);
mDuration *= timeCoef;
mDuration = (int) (mDuration * timeCoef);
}
}
......
......@@ -393,7 +393,7 @@ public class StripLayoutHelper implements StripLayoutTab.StripLayoutTabDelegate
float delta = calculateOffsetToMakeTabVisible(tab, true, true, true);
// During this resize, mMinScrollOffset will be changing, so the scroll effect
// cannot be properly animated. Jump to the new scroll offset instead.
mScrollOffset += delta;
mScrollOffset = (int) (mScrollOffset + delta);
}
updateStrip();
......@@ -1631,7 +1631,7 @@ public class StripLayoutHelper implements StripLayoutTab.StripLayoutTabDelegate
if (shouldAnimate && !mAnimationsDisabledForTesting) {
mScroller.startScroll(mScrollOffset, 0, (int) delta, 0, time, EXPAND_DURATION_MS);
} else {
mScrollOffset += delta;
mScrollOffset = (int) (mScrollOffset + delta);
}
}
......
......@@ -771,8 +771,9 @@ public class PageInfoPopup implements OnClickListener {
if (mIsBottomPopup) {
// In Chrome Home, the full URL is showing at all times; give the scroll
// view a max height so long URLs don't consume the entire screen.
dialogMaxHeight -=
mContext.getResources().getDimension(R.dimen.min_touch_target_size);
dialogMaxHeight = (int) (dialogMaxHeight
- mContext.getResources().getDimension(
R.dimen.min_touch_target_size));
}
heightMeasureSpec =
......
......@@ -100,13 +100,13 @@ class BitmapUtils {
if (width < size) {
float scale = (float) size / width;
width = size;
height *= scale;
height = (int) (height * scale);
}
if (height < size) {
float scale = (float) size / height;
height = size;
width *= scale;
width = (int) (width * scale);
}
return Bitmap.createScaledBitmap(bitmap, width, height, true);
......
......@@ -232,8 +232,10 @@ public class DataReductionSiteBreakdownView extends LinearLayout {
mTableLayout.addView(row, i + 1);
} else {
numRemainingSites++;
everythingElseDataUsage += mDataUseItems.get(i).getDataUsed();
everythingElseDataSavings += mDataUseItems.get(i).getDataSaved();
everythingElseDataUsage =
(int) (everythingElseDataUsage + mDataUseItems.get(i).getDataUsed());
everythingElseDataSavings =
(int) (everythingElseDataSavings + mDataUseItems.get(i).getDataSaved());
}
}
......
......@@ -126,8 +126,8 @@ public class MathUtils {
float scale = Math.max(
(float) targetWidth / dimensions[0],
(float) targetHeight / dimensions[1]);
dimensions[0] *= scale;
dimensions[1] *= scale;
dimensions[0] = (int) (dimensions[0] * scale);
dimensions[1] = (int) (dimensions[1] * scale);
return scale;
}
......
......@@ -94,8 +94,8 @@ public class ViewUtils {
outPosition[1] = 0;
if (rootView == null || childView == rootView) return;
while (childView != null) {
outPosition[0] += childView.getX();
outPosition[1] += childView.getY();
outPosition[0] = (int) (outPosition[0] + childView.getX());
outPosition[1] = (int) (outPosition[1] + childView.getY());
if (childView.getParent() == rootView) break;
childView = (View) childView.getParent();
}
......
......@@ -662,8 +662,10 @@ public class BottomSheetContentController
ViewUtils.getRelativeDrawPosition(rootView, selectedItemView, outPosition);
// Center the star's start position over the icon in the middle of the button.
outPosition[0] += selectedItemView.getWidth() / 2.f - starFull.getIntrinsicWidth() / 2.f;
outPosition[1] += selectedItemView.getHeight() / 2.f - starFull.getIntrinsicHeight() / 2.f;
outPosition[0] = (int) (outPosition[0]
+ (selectedItemView.getWidth() / 2.f - starFull.getIntrinsicWidth() / 2.f));
outPosition[1] = (int) (outPosition[1]
+ (selectedItemView.getHeight() / 2.f - starFull.getIntrinsicHeight() / 2.f));
for (int i = 0; i < 5; i++) {
MagicStar star = new MagicStar(getContext(), outPosition[0], outPosition[1], 100 * i,
......
......@@ -74,7 +74,7 @@ public class SimulatedTouchInputStrategy implements InputStrategyInterface {
// factor to make the interaction more intuitive and useful for our scenario.
ViewConfiguration config = ViewConfiguration.get(context);
int scaledDoubleTapSlopInPx = config.getScaledDoubleTapSlop();
scaledDoubleTapSlopInPx *= DOUBLE_TAP_SLOP_SCALE_FACTOR;
scaledDoubleTapSlopInPx = (int) (scaledDoubleTapSlopInPx * DOUBLE_TAP_SLOP_SCALE_FACTOR);
mDoubleTapSlopSquareInPx = scaledDoubleTapSlopInPx * scaledDoubleTapSlopInPx;
mRenderData.drawCursor = false;
......
......@@ -76,7 +76,7 @@ public class TouchEventData {
// MotionEvent angle is measured in radians and our API expects a positive value in degrees.
if (touchPointAngleInRadians < 0.0f) {
touchPointAngleInRadians += (2 * Math.PI);
touchPointAngleInRadians = (float) (touchPointAngleInRadians + (2 * Math.PI));
}
mTouchPointAngleInDegrees = (float) Math.toDegrees(touchPointAngleInRadians);
}
......
......@@ -239,7 +239,7 @@ public class UiUtils {
// keyboard height. In certain cases this also means including the height of the
// Android navigation.
final float density = context.getResources().getDisplayMetrics().density;
bottomMargin -= KEYBOARD_DETECT_BOTTOM_THRESHOLD_DP * density;
bottomMargin = (int) (bottomMargin - KEYBOARD_DETECT_BOTTOM_THRESHOLD_DP * density);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment