@@ -94,6 +94,7 @@ public void onButtonClickAnimationEnd(@NonNull CircleMenuView view, int buttonIn
94
94
private float mDistance ;
95
95
96
96
private final List <View > mButtons = new ArrayList <>();
97
+ private final Rect mButtonRect = new Rect ();
97
98
98
99
public CircleMenuView (@ NonNull Context context , @ Nullable AttributeSet attrs ) {
99
100
super (context , attrs );
@@ -130,16 +131,20 @@ private void init(@NonNull Context context, @Nullable AttributeSet attrs,
130
131
final int colorArrayId = a .getResourceId (R .styleable .CircleMenuView_button_colors , 0 );
131
132
132
133
final TypedArray iconsIds = getResources ().obtainTypedArray (iconArrayId );
133
- final int [] colorsIds = getResources ().getIntArray (colorArrayId );
134
+ try {
135
+ final int [] colorsIds = getResources ().getIntArray (colorArrayId );
134
136
135
- final int buttonsCount = Math .min (iconsIds .length (), colorsIds .length );
137
+ final int buttonsCount = Math .min (iconsIds .length (), colorsIds .length );
136
138
137
- icons = new ArrayList <>(buttonsCount );
138
- colors = new ArrayList <>(buttonsCount );
139
+ icons = new ArrayList <>(buttonsCount );
140
+ colors = new ArrayList <>(buttonsCount );
139
141
140
- for (int i = 0 ; i < buttonsCount ; i ++) {
141
- icons .add (iconsIds .getResourceId (i , -1 ));
142
- colors .add (colorsIds [i ]);
142
+ for (int i = 0 ; i < buttonsCount ; i ++) {
143
+ icons .add (iconsIds .getResourceId (i , -1 ));
144
+ colors .add (colorsIds [i ]);
145
+ }
146
+ } finally {
147
+ iconsIds .recycle ();
143
148
}
144
149
}
145
150
@@ -254,15 +259,14 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
254
259
button .setY (y );
255
260
}
256
261
257
- final Rect buttonRect = new Rect ();
258
- mMenuButton .getContentRect (buttonRect );
262
+ mMenuButton .getContentRect (mButtonRect );
259
263
260
264
mRingView .setX (getWidth () / 2f - mRingView .getWidth () / 2f );
261
265
mRingView .setY (getHeight () / 2f - mRingView .getHeight () / 2f );
262
- mRingView .setStrokeWidth (buttonRect .width ());
266
+ mRingView .setStrokeWidth (mButtonRect .width ());
263
267
264
268
if (mDistance == -1 ) {
265
- mDistance = buttonRect .width () * 1.5f ;
269
+ mDistance = mButtonRect .width () * 1.5f ;
266
270
}
267
271
268
272
final LayoutParams lp = (LayoutParams ) mRingView .getLayoutParams ();
@@ -320,14 +324,12 @@ public void onAnimationEnd(Animator animation) {
320
324
321
325
final float elevation = mMenuButton .getCompatElevation ();
322
326
327
+ mRingView .setVisibility (View .INVISIBLE );
323
328
mRingView .setStartAngle (startAngle );
324
329
mRingView .setAngle (0 );
325
- mRingView .setAlpha (1f );
326
- mRingView .setScaleX (1f );
327
- mRingView .setScaleY (1f );
328
330
mRingView .setStrokeColor (button .getBackgroundTintList ().getDefaultColor ());
329
331
330
- final ObjectAnimator angle = ObjectAnimator .ofFloat (mRingView , "angle" , 360 );
332
+ final ObjectAnimator ring = ObjectAnimator .ofFloat (mRingView , "angle" , 360 );
331
333
final ObjectAnimator scaleX = ObjectAnimator .ofFloat (mRingView , "scaleX" , 1f , 1.3f );
332
334
final ObjectAnimator scaleY = ObjectAnimator .ofFloat (mRingView , "scaleY" , 1f , 1.3f );
333
335
final ObjectAnimator visible = ObjectAnimator .ofFloat (mRingView , "alpha" , 1f , 0f );
@@ -336,7 +338,7 @@ public void onAnimationEnd(Animator animation) {
336
338
lastSet .playTogether (scaleX , scaleY , visible , getCloseMenuAnimation ());
337
339
338
340
final AnimatorSet firstSet = new AnimatorSet ();
339
- firstSet .playTogether (rotateButton , angle );
341
+ firstSet .playTogether (rotateButton , ring );
340
342
firstSet .addListener (new AnimatorListenerAdapter () {
341
343
@ Override
342
344
public void onAnimationStart (Animator animation ) {
@@ -347,6 +349,9 @@ public void onAnimationStart(Animator animation) {
347
349
button .setCompatElevation (elevation + 2 );
348
350
ViewCompat .setZ (mRingView , elevation + 1 );
349
351
}
352
+ mRingView .setScaleX (1f );
353
+ mRingView .setScaleY (1f );
354
+ mRingView .setVisibility (View .VISIBLE );
350
355
}
351
356
@ Override
352
357
public void onAnimationEnd (Animator animation ) {
0 commit comments