Skip to content

Commit

Permalink
[BottomAppBar] change cornersize to float to avoid truncation errors
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 367430538
  • Loading branch information
ymarian authored and afohrman committed Apr 9, 2021
1 parent 5a35bf7 commit 8e9b680
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ boolean setFabDiameter(@Px int diameter) {
return false;
}

void setFabCornerSize(@Px int radius) {
void setFabCornerSize(@Dimension float radius) {
if (radius != getTopEdgeTreatment().getFabCornerRadius()) {
getTopEdgeTreatment().setFabCornerSize(radius);
materialShapeDrawable.invalidateSelf();
Expand Down Expand Up @@ -1036,7 +1036,7 @@ public void onLayoutChange(
child.setFabDiameter(height);

// Assume symmetrical corners
int cornerSize = (int) fab.getShapeAppearanceModel().getTopLeftCornerSize()
float cornerSize = fab.getShapeAppearanceModel().getTopLeftCornerSize()
.getCornerSize(new RectF(fabContentRect));

child.setFabCornerSize(cornerSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class BottomAppBarTopEdgeTreatment extends EdgeTreatment implements Clone
private float fabDiameter;
private float cradleVerticalOffset;
private float horizontalOffset;
private int fabCornerSize = -1;
private float fabCornerSize = -1f;

/**
* @param fabMargin the margin in pixels between the cutout and the fab.
Expand Down Expand Up @@ -101,7 +101,7 @@ public void getEdgePath(
// Calculate the X distance between the center of the two adjacent circles using pythagorean
// theorem.
float cornerSize = fabCornerSize * interpolation;
boolean useCircleCutout = fabCornerSize == -1 || abs(fabCornerSize * 2 - fabDiameter) < .1f;
boolean useCircleCutout = fabCornerSize == -1 || abs(fabCornerSize * 2f - fabDiameter) < .1f;
float arcOffset = 0;
if (!useCircleCutout) {
verticalOffset = 0;
Expand Down Expand Up @@ -251,11 +251,11 @@ void setFabCradleRoundedCornerRadius(float roundedCornerRadius) {
this.roundedCornerRadius = roundedCornerRadius;
}

public int getFabCornerRadius() {
public float getFabCornerRadius() {
return fabCornerSize;
}

public void setFabCornerSize(int size) {
public void setFabCornerSize(float size) {
this.fabCornerSize = size;
}
}

0 comments on commit 8e9b680

Please sign in to comment.