@@ -68,18 +68,21 @@ private void init(Context context, AttributeSet attrs) {
6868 private void updateTint () {
6969 if (tintColor != Color .TRANSPARENT ) {
7070 Drawable [] drawables = getCompoundDrawables ();
71- for (Drawable drawable : drawables ) {
71+ if (drawables .length != DRAWABLES_LENGTH ) return ;
72+
73+ Drawable [] wrappedDrawables = new Drawable [DRAWABLES_LENGTH ];
74+ for (int i = 0 ; i < DRAWABLES_LENGTH ; i ++) {
75+ Drawable drawable = drawables [i ];
7276 if (drawable != null ) {
7377 Drawable wrappedDrawable = DrawableCompat .wrap (drawable ).mutate ();
7478 DrawableCompat .setTint (wrappedDrawable , tintColor );
79+ wrappedDrawables [i ] = wrappedDrawable ;
7580 }
7681 }
77- if (drawables .length == DRAWABLES_LENGTH ) {
78- setCompoundDrawablesWithIntrinsicBounds (drawables [DRAWABLE_LEFT_POSITION ],
79- drawables [DRAWABLE_TOP_POSITION ],
80- drawables [DRAWABLE_RIGHT_POSITION ],
81- drawables [DRAWABLE_BOTTOM_POSITION ]);
82- }
82+ setCompoundDrawablesWithIntrinsicBounds (wrappedDrawables [DRAWABLE_LEFT_POSITION ],
83+ wrappedDrawables [DRAWABLE_TOP_POSITION ],
84+ wrappedDrawables [DRAWABLE_RIGHT_POSITION ],
85+ wrappedDrawables [DRAWABLE_BOTTOM_POSITION ]);
8386 }
8487 }
8588
0 commit comments