@@ -234,17 +234,30 @@ private void setBorderAttrs() {
234
234
animateImagesExitDuration , animateTextsExit , animateTextsExitDuration , lastPosition , buttonPadding ,
235
235
buttonPaddingLeft , buttonPaddingRight , buttonPaddingTop , buttonPaddingBottom , groupBackgroundColor , dividerBackgroundColor ,
236
236
dividerPadding , dividerSize , dividerRadius , bottomLineSize , bottomLineRadius , selectorSize , selectorRadius , initialPosition ,
237
- selectorDividerSize , selectorDividerRadius , selectorDividerColor , selectorDividerPadding , checkedButtonId ;
237
+ selectorDividerSize , selectorDividerRadius , selectorDividerColor , selectorDividerPadding , checkedButtonId ,
238
+ animateTextsTextColorFrom , animateTextsTextColorTo , animateTextsTextColorDuration ,
239
+ animateDrawablesTintColorFrom , animateDrawablesTintColorTo , animateDrawablesTintColorDuration ;
238
240
239
241
private float radius , animateImagesScale , animateTextsScale ;
240
242
241
243
private boolean bottomLineBringToFront , selectorBringToFront , selectorAboveOfBottomLine , selectorTop , selectorBottom , hasPadding ,
242
244
hasPaddingLeft , hasPaddingRight , hasPaddingTop , hasPaddingBottom , hasDividerBackgroundColor , clickable , enabled ,
243
- enableDeselection , hasEnabled , hasClickable , hasBorder , hasAnimateImages , hasAnimateTexts , hasAnimation , selectorFullSize ;
245
+ enableDeselection , hasEnabled , hasClickable , hasBorder , hasAnimateImages , hasAnimateTexts , hasAnimation , selectorFullSize ,
246
+ hasAnimateTextsColor , hasAnimateDrawablesColor ;
244
247
245
248
private void getAttributes (AttributeSet attrs ) {
246
249
TypedArray ta = getContext ().obtainStyledAttributes (attrs , R .styleable .RadioRealButtonGroup );
247
250
251
+ animateTextsTextColorFrom = ta .getColor (R .styleable .RadioRealButtonGroup_rrbg_animateTexts_textColorFrom , Color .BLACK );
252
+ animateTextsTextColorTo = ta .getColor (R .styleable .RadioRealButtonGroup_rrbg_animateTexts_textColorTo , Color .WHITE );
253
+ hasAnimateTextsColor = ta .hasValue (R .styleable .RadioRealButtonGroup_rrbg_animateTexts_textColorTo );
254
+ animateTextsTextColorDuration = ta .getColor (R .styleable .RadioRealButtonGroup_rrbg_animateTexts_textColorDuration , 500 );
255
+
256
+ animateDrawablesTintColorFrom = ta .getColor (R .styleable .RadioRealButtonGroup_rrbg_animateDrawables_tintColorFrom , Color .BLACK );
257
+ animateDrawablesTintColorTo = ta .getColor (R .styleable .RadioRealButtonGroup_rrbg_animateDrawables_tintColorTo , Color .WHITE );
258
+ hasAnimateDrawablesColor = ta .hasValue (R .styleable .RadioRealButtonGroup_rrbg_animateDrawables_tintColorTo );
259
+ animateDrawablesTintColorDuration = ta .getColor (R .styleable .RadioRealButtonGroup_rrbg_animateDrawables_tintColorDuration , 500 );
260
+
248
261
bottomLineColor = ta .getColor (R .styleable .RadioRealButtonGroup_rrbg_bottomLineColor , Color .GRAY );
249
262
bottomLineSize = ta .getDimensionPixelSize (R .styleable .RadioRealButtonGroup_rrbg_bottomLineSize , 0 );
250
263
bottomLineBringToFront = ta .getBoolean (R .styleable .RadioRealButtonGroup_rrbg_bottomLineBringToFront , false );
@@ -366,9 +379,20 @@ else if (checkedButtonId == NO_ID && button.isChecked())
366
379
button .bounceDrawable (animateImagesScale );
367
380
if (hasAnimateTexts )
368
381
button .bounceText (animateTextsScale );
369
- } else
382
+ if (hasAnimateTextsColor )
383
+ button .setTextColor (animateTextsTextColorTo );
384
+ if (hasAnimateDrawablesColor )
385
+ button .setDrawableTint (animateDrawablesTintColorTo );
386
+
387
+ } else {
370
388
button .setChecked (false );
371
389
390
+ if (hasAnimateTextsColor )
391
+ button .setTextColor (animateTextsTextColorFrom );
392
+ if (hasAnimateDrawablesColor )
393
+ button .setDrawableTint (animateDrawablesTintColorFrom );
394
+ }
395
+
372
396
initButtonListener (button , position );
373
397
setButtonPadding (button );
374
398
container .addView (button );
@@ -484,11 +508,10 @@ private void makeSelection(int position, boolean isToggledByTouch, boolean hasAn
484
508
if (null != buttonOut )
485
509
buttonOut .setChecked (false );
486
510
} else {
487
- if (lastPosition == position && buttonIn .isChecked ()){
511
+ if (lastPosition == position && buttonIn .isChecked ()) {
488
512
buttonIn .setChecked (false );
489
513
position = -1 ;
490
- }
491
- else
514
+ } else
492
515
buttonIn .setChecked (true );
493
516
}
494
517
@@ -525,13 +548,21 @@ private void animateExit(RadioRealButton button, boolean hasAnimation) {
525
548
button .bounceText (1 , animateTextsExitDuration , interpolatorTextExit , hasAnimation );
526
549
if (hasAnimateImages )
527
550
button .bounceDrawable (1 , animateImagesExitDuration , interpolatorImageExit , hasAnimation );
551
+ if (hasAnimateTextsColor )
552
+ button .colorTransitionText (animateTextsTextColorTo , animateTextsTextColorFrom , animateTextsTextColorDuration , hasAnimation );
553
+ if (hasAnimateDrawablesColor )
554
+ button .colorTransitionDrawable (animateDrawablesTintColorTo , animateDrawablesTintColorFrom , animateDrawablesTintColorDuration , hasAnimation );
528
555
}
529
556
530
557
private void animateEnter (RadioRealButton button , boolean hasAnimation ) {
531
558
if (hasAnimateTexts )
532
559
button .bounceText (animateTextsScale , animateTextsDuration , interpolatorText , hasAnimation );
533
560
if (hasAnimateImages )
534
561
button .bounceDrawable (animateImagesScale , animateImagesDuration , interpolatorImage , hasAnimation );
562
+ if (hasAnimateTextsColor )
563
+ button .colorTransitionText (animateTextsTextColorFrom , animateTextsTextColorTo , animateTextsTextColorDuration , hasAnimation );
564
+ if (hasAnimateDrawablesColor )
565
+ button .colorTransitionDrawable (animateDrawablesTintColorFrom , animateDrawablesTintColorTo , animateDrawablesTintColorDuration , hasAnimation );
535
566
}
536
567
/* DRAWABLE AND TEXT ANIMATION ENDS */
537
568
@@ -701,12 +732,63 @@ public boolean onLongClick(View v) {
701
732
702
733
public interface OnLongClickedButtonListener {
703
734
boolean onLongClickedButton (RadioRealButton button , int position );
735
+
704
736
}
705
737
706
738
/**
707
739
* LISTENERS --- ENDS
708
740
*/
709
741
742
+
743
+ public int getAnimateTextsTextColorFrom () {
744
+ return animateTextsTextColorFrom ;
745
+ }
746
+
747
+ public void setAnimateTextsTextColorFrom (int animateTextsTextColorFrom ) {
748
+ this .animateTextsTextColorFrom = animateTextsTextColorFrom ;
749
+ }
750
+
751
+ public int getAnimateTextsTextColorTo () {
752
+ return animateTextsTextColorTo ;
753
+ }
754
+
755
+ public void setAnimateTextsTextColorTo (int animateTextsTextColorTo ) {
756
+ this .animateTextsTextColorTo = animateTextsTextColorTo ;
757
+ }
758
+
759
+ public int getAnimateTextsTextColorDuration () {
760
+ return animateTextsTextColorDuration ;
761
+ }
762
+
763
+ public void setAnimateTextsTextColorDuration (int animateTextsTextColorDuration ) {
764
+ this .animateTextsTextColorDuration = animateTextsTextColorDuration ;
765
+ }
766
+
767
+ public int getAnimateDrawablesTintColorFrom () {
768
+ return animateDrawablesTintColorFrom ;
769
+ }
770
+
771
+ public void setAnimateDrawablesTintColorFrom (int animateDrawablesTintColorFrom ) {
772
+ this .animateDrawablesTintColorFrom = animateDrawablesTintColorFrom ;
773
+ }
774
+
775
+ public int getAnimateDrawablesTintColorTo () {
776
+ return animateDrawablesTintColorTo ;
777
+ }
778
+
779
+ public void setAnimateDrawablesTintColorTo (int animateDrawablesTintColorTo ) {
780
+ this .animateDrawablesTintColorTo = animateDrawablesTintColorTo ;
781
+ }
782
+
783
+ public int getAnimateDrawablesTintColorDuration () {
784
+ return animateDrawablesTintColorDuration ;
785
+ }
786
+
787
+ public void setAnimateDrawablesTintColorDuration (int animateDrawablesTintColorDuration ) {
788
+ this .animateDrawablesTintColorDuration = animateDrawablesTintColorDuration ;
789
+ }
790
+
791
+
710
792
public List <RadioRealButton > getButtons () {
711
793
return buttons ;
712
794
}
0 commit comments