@@ -257,17 +257,17 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
257
257
final Rect buttonRect = new Rect ();
258
258
mMenuButton .getContentRect (buttonRect );
259
259
260
- mRingView .setX (getWidth () / 2 - mRingView .getWidth () / 2 );
261
- mRingView .setY (getHeight () / 2 - mRingView .getHeight () / 2 );
260
+ mRingView .setX (getWidth () / 2f - mRingView .getWidth () / 2f );
261
+ mRingView .setY (getHeight () / 2f - mRingView .getHeight () / 2f );
262
262
mRingView .setStrokeWidth (buttonRect .width ());
263
263
264
264
if (mDistance == -1 ) {
265
265
mDistance = buttonRect .width () * 1.5f ;
266
266
}
267
267
268
268
final LayoutParams lp = (LayoutParams ) mRingView .getLayoutParams ();
269
- lp .width = (int ) mDistance * 2 ;
270
- lp .height = (int ) mDistance * 2 ;
269
+ lp .width = (int ) ( mDistance * 2 ) ;
270
+ lp .height = (int ) ( mDistance * 2 ) ;
271
271
mRingView .setLayoutParams (lp );
272
272
}
273
273
@@ -298,24 +298,23 @@ public void onAnimationEnd(Animator animation) {
298
298
299
299
private Animator getButtonClickAnimation (final @ NonNull FloatingActionButton button ) {
300
300
final int buttonNumber = mButtons .indexOf (button ) + 1 ;
301
- final int stepAngle = 360 / mButtons .size ();
302
- final int startAngle = -90 - stepAngle + stepAngle * buttonNumber ;
303
-
304
- final Rect buttonRect = new Rect ();
305
- mMenuButton .getContentRect (buttonRect );
301
+ final float stepAngle = 360f / mButtons .size ();
302
+ final float startAngle = -90 - stepAngle + stepAngle * buttonNumber ;
306
303
307
304
final float x = (float ) Math .cos (Math .toRadians (startAngle )) * mDistance ;
308
305
final float y = (float ) Math .sin (Math .toRadians (startAngle )) * mDistance ;
309
306
310
- button .setPivotX (button .getPivotX () - x );
311
- button .setPivotY (button .getPivotY () - y );
307
+ final float pivotX = button .getPivotX ();
308
+ final float pivotY = button .getPivotY ();
309
+ button .setPivotX (pivotX - x );
310
+ button .setPivotY (pivotY - y );
312
311
313
312
final ObjectAnimator rotateButton = ObjectAnimator .ofFloat (button , "rotation" , 0f , 360f );
314
313
rotateButton .addListener (new AnimatorListenerAdapter () {
315
314
@ Override
316
315
public void onAnimationEnd (Animator animation ) {
317
- button .setPivotX (buttonRect . width () / 2 );
318
- button .setPivotY (buttonRect . height () / 2 );
316
+ button .setPivotX (pivotX );
317
+ button .setPivotY (pivotY );
319
318
}
320
319
});
321
320
0 commit comments