Skip to content

Commit

Permalink
Fixup bad ANDROIDLINT Automatic Fix (#42694)
Browse files Browse the repository at this point in the history
Summary:

D53115471 commited all the automatically fixable lints by `ANDROIDLINT`. When I looked again, closer, there was one automatic fix that I'm fairly sure is incorrect.

Before:

`outTransform.postTranslate((int) (dx + 0.5f), (int) (dy + 0.5f));`

After:

`outTransform.postTranslate((dx + 0.5f), (dy + 0.5f));`

I think the linter did this because the underlying API accepts a float, so this was (incorrectly) seen as an extraneous cast causing precision loss, but the previous behavior was using the cast and addition to round the float, instead of adding 0.5 to it.

This replaces the call with an explicit rounding, for the same behavior as before (though, I'm not sure if the rounding is intentional, since in and out are both fp).


Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D53158801
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Jan 29, 2024
1 parent 5d559c1 commit 65e4630
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void getTransformImpl(
float dx = parentRect.left;
float dy = parentRect.top;
outTransform.setScale(scale, scale);
outTransform.postTranslate((dx + 0.5f), (dy + 0.5f));
outTransform.postTranslate(Math.round(dx), Math.round(dy));
}

@Override
Expand Down

0 comments on commit 65e4630

Please sign in to comment.