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 ...@@ -23,8 +23,6 @@ import colorama
ERRORPRONE_WARNINGS_TO_TURN_OFF = [ ERRORPRONE_WARNINGS_TO_TURN_OFF = [
# TODO(crbug.com/801210): Follow steps in bug. # TODO(crbug.com/801210): Follow steps in bug.
'SynchronizeOnNonFinalField', 'SynchronizeOnNonFinalField',
# TODO(crbug.com/801268): Follow steps in bug.
'NarrowingCompoundAssignment',
# TODO(crbug.com/802073): Follow steps in bug. # TODO(crbug.com/802073): Follow steps in bug.
'TypeParameterUnusedInFormals', 'TypeParameterUnusedInFormals',
# TODO(crbug.com/802075): Follow steps in bug. # TODO(crbug.com/802075): Follow steps in bug.
...@@ -98,6 +96,7 @@ ERRORPRONE_WARNINGS_TO_ERROR = [ ...@@ -98,6 +96,7 @@ ERRORPRONE_WARNINGS_TO_ERROR = [
'FloatingPointLiteralPrecision', 'FloatingPointLiteralPrecision',
'JavaLangClash', 'JavaLangClash',
'MissingOverride', 'MissingOverride',
'NarrowingCompoundAssignment',
'ParameterName', 'ParameterName',
'StaticQualifiedUsingExpression', 'StaticQualifiedUsingExpression',
'UseCorrectAssertInTests', 'UseCorrectAssertInTests',
......
...@@ -252,8 +252,8 @@ public class StackScroller { ...@@ -252,8 +252,8 @@ public class StackScroller {
float oldVelocityY = mScrollerY.mCurrVelocity; float oldVelocityY = mScrollerY.mCurrVelocity;
if (Math.signum(velocityX) == Math.signum(oldVelocityX) if (Math.signum(velocityX) == Math.signum(oldVelocityX)
&& Math.signum(velocityY) == Math.signum(oldVelocityY)) { && Math.signum(velocityY) == Math.signum(oldVelocityY)) {
velocityX += oldVelocityX; velocityX = (int) (velocityX + oldVelocityX);
velocityY += oldVelocityY; velocityY = (int) (velocityY + oldVelocityY);
} }
} }
...@@ -411,7 +411,7 @@ public class StackScroller { ...@@ -411,7 +411,7 @@ public class StackScroller {
final float tInf = SPLINE_TIME[index]; final float tInf = SPLINE_TIME[index];
final float tSup = SPLINE_TIME[index + 1]; final float tSup = SPLINE_TIME[index + 1];
final float timeCoef = tInf + (x - xInf) / (xSup - xInf) * (tSup - tInf); 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 ...@@ -393,7 +393,7 @@ public class StripLayoutHelper implements StripLayoutTab.StripLayoutTabDelegate
float delta = calculateOffsetToMakeTabVisible(tab, true, true, true); float delta = calculateOffsetToMakeTabVisible(tab, true, true, true);
// During this resize, mMinScrollOffset will be changing, so the scroll effect // During this resize, mMinScrollOffset will be changing, so the scroll effect
// cannot be properly animated. Jump to the new scroll offset instead. // cannot be properly animated. Jump to the new scroll offset instead.
mScrollOffset += delta; mScrollOffset = (int) (mScrollOffset + delta);
} }
updateStrip(); updateStrip();
...@@ -1631,7 +1631,7 @@ public class StripLayoutHelper implements StripLayoutTab.StripLayoutTabDelegate ...@@ -1631,7 +1631,7 @@ public class StripLayoutHelper implements StripLayoutTab.StripLayoutTabDelegate
if (shouldAnimate && !mAnimationsDisabledForTesting) { if (shouldAnimate && !mAnimationsDisabledForTesting) {
mScroller.startScroll(mScrollOffset, 0, (int) delta, 0, time, EXPAND_DURATION_MS); mScroller.startScroll(mScrollOffset, 0, (int) delta, 0, time, EXPAND_DURATION_MS);
} else { } else {
mScrollOffset += delta; mScrollOffset = (int) (mScrollOffset + delta);
} }
} }
......
...@@ -771,8 +771,9 @@ public class PageInfoPopup implements OnClickListener { ...@@ -771,8 +771,9 @@ public class PageInfoPopup implements OnClickListener {
if (mIsBottomPopup) { if (mIsBottomPopup) {
// In Chrome Home, the full URL is showing at all times; give the scroll // 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. // view a max height so long URLs don't consume the entire screen.
dialogMaxHeight -= dialogMaxHeight = (int) (dialogMaxHeight
mContext.getResources().getDimension(R.dimen.min_touch_target_size); - mContext.getResources().getDimension(
R.dimen.min_touch_target_size));
} }
heightMeasureSpec = heightMeasureSpec =
......
...@@ -100,13 +100,13 @@ class BitmapUtils { ...@@ -100,13 +100,13 @@ class BitmapUtils {
if (width < size) { if (width < size) {
float scale = (float) size / width; float scale = (float) size / width;
width = size; width = size;
height *= scale; height = (int) (height * scale);
} }
if (height < size) { if (height < size) {
float scale = (float) size / height; float scale = (float) size / height;
height = size; height = size;
width *= scale; width = (int) (width * scale);
} }
return Bitmap.createScaledBitmap(bitmap, width, height, true); return Bitmap.createScaledBitmap(bitmap, width, height, true);
......
...@@ -232,8 +232,10 @@ public class DataReductionSiteBreakdownView extends LinearLayout { ...@@ -232,8 +232,10 @@ public class DataReductionSiteBreakdownView extends LinearLayout {
mTableLayout.addView(row, i + 1); mTableLayout.addView(row, i + 1);
} else { } else {
numRemainingSites++; numRemainingSites++;
everythingElseDataUsage += mDataUseItems.get(i).getDataUsed(); everythingElseDataUsage =
everythingElseDataSavings += mDataUseItems.get(i).getDataSaved(); (int) (everythingElseDataUsage + mDataUseItems.get(i).getDataUsed());
everythingElseDataSavings =
(int) (everythingElseDataSavings + mDataUseItems.get(i).getDataSaved());
} }
} }
......
...@@ -126,8 +126,8 @@ public class MathUtils { ...@@ -126,8 +126,8 @@ public class MathUtils {
float scale = Math.max( float scale = Math.max(
(float) targetWidth / dimensions[0], (float) targetWidth / dimensions[0],
(float) targetHeight / dimensions[1]); (float) targetHeight / dimensions[1]);
dimensions[0] *= scale; dimensions[0] = (int) (dimensions[0] * scale);
dimensions[1] *= scale; dimensions[1] = (int) (dimensions[1] * scale);
return scale; return scale;
} }
......
...@@ -94,8 +94,8 @@ public class ViewUtils { ...@@ -94,8 +94,8 @@ public class ViewUtils {
outPosition[1] = 0; outPosition[1] = 0;
if (rootView == null || childView == rootView) return; if (rootView == null || childView == rootView) return;
while (childView != null) { while (childView != null) {
outPosition[0] += childView.getX(); outPosition[0] = (int) (outPosition[0] + childView.getX());
outPosition[1] += childView.getY(); outPosition[1] = (int) (outPosition[1] + childView.getY());
if (childView.getParent() == rootView) break; if (childView.getParent() == rootView) break;
childView = (View) childView.getParent(); childView = (View) childView.getParent();
} }
......
...@@ -662,8 +662,10 @@ public class BottomSheetContentController ...@@ -662,8 +662,10 @@ public class BottomSheetContentController
ViewUtils.getRelativeDrawPosition(rootView, selectedItemView, outPosition); ViewUtils.getRelativeDrawPosition(rootView, selectedItemView, outPosition);
// Center the star's start position over the icon in the middle of the button. // 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[0] = (int) (outPosition[0]
outPosition[1] += selectedItemView.getHeight() / 2.f - starFull.getIntrinsicHeight() / 2.f; + (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++) { for (int i = 0; i < 5; i++) {
MagicStar star = new MagicStar(getContext(), outPosition[0], outPosition[1], 100 * i, MagicStar star = new MagicStar(getContext(), outPosition[0], outPosition[1], 100 * i,
......
...@@ -74,7 +74,7 @@ public class SimulatedTouchInputStrategy implements InputStrategyInterface { ...@@ -74,7 +74,7 @@ public class SimulatedTouchInputStrategy implements InputStrategyInterface {
// factor to make the interaction more intuitive and useful for our scenario. // factor to make the interaction more intuitive and useful for our scenario.
ViewConfiguration config = ViewConfiguration.get(context); ViewConfiguration config = ViewConfiguration.get(context);
int scaledDoubleTapSlopInPx = config.getScaledDoubleTapSlop(); int scaledDoubleTapSlopInPx = config.getScaledDoubleTapSlop();
scaledDoubleTapSlopInPx *= DOUBLE_TAP_SLOP_SCALE_FACTOR; scaledDoubleTapSlopInPx = (int) (scaledDoubleTapSlopInPx * DOUBLE_TAP_SLOP_SCALE_FACTOR);
mDoubleTapSlopSquareInPx = scaledDoubleTapSlopInPx * scaledDoubleTapSlopInPx; mDoubleTapSlopSquareInPx = scaledDoubleTapSlopInPx * scaledDoubleTapSlopInPx;
mRenderData.drawCursor = false; mRenderData.drawCursor = false;
......
...@@ -76,7 +76,7 @@ public class TouchEventData { ...@@ -76,7 +76,7 @@ public class TouchEventData {
// MotionEvent angle is measured in radians and our API expects a positive value in degrees. // MotionEvent angle is measured in radians and our API expects a positive value in degrees.
if (touchPointAngleInRadians < 0.0f) { if (touchPointAngleInRadians < 0.0f) {
touchPointAngleInRadians += (2 * Math.PI); touchPointAngleInRadians = (float) (touchPointAngleInRadians + (2 * Math.PI));
} }
mTouchPointAngleInDegrees = (float) Math.toDegrees(touchPointAngleInRadians); mTouchPointAngleInDegrees = (float) Math.toDegrees(touchPointAngleInRadians);
} }
......
...@@ -239,7 +239,7 @@ public class UiUtils { ...@@ -239,7 +239,7 @@ public class UiUtils {
// keyboard height. In certain cases this also means including the height of the // keyboard height. In certain cases this also means including the height of the
// Android navigation. // Android navigation.
final float density = context.getResources().getDisplayMetrics().density; 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