Skip to content

Commit

Permalink
Fix issue #37
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFinestArtist committed Mar 15, 2016
1 parent 169f64c commit 51c4b1e
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.VectorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
Expand Down Expand Up @@ -827,7 +828,6 @@ protected int getMaxWidth() {
}

protected void updateIcon(ImageButton icon, @DrawableRes int drawableRes) {
VectorDrawableCompat drawable = (VectorDrawableCompat) ContextCompat.getDrawable(this, drawableRes);

int[][] states = new int[][]{
new int[]{-android.R.attr.state_enabled}, // disabled
Expand All @@ -842,8 +842,17 @@ protected void updateIcon(ImageButton icon, @DrawableRes int drawableRes) {
};

ColorStateList colorStateList = new ColorStateList(states, colors);
drawable.setTintList(colorStateList);
icon.setImageDrawable(drawable);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
VectorDrawable drawable = (VectorDrawable) ContextCompat.getDrawable(this, drawableRes);
drawable.setTintList(colorStateList);
icon.setImageDrawable(drawable);

} else {
VectorDrawableCompat drawable = (VectorDrawableCompat) ContextCompat.getDrawable(this, drawableRes);
drawable.setTintList(colorStateList);
icon.setImageDrawable(drawable);
}
}

@Override
Expand Down

0 comments on commit 51c4b1e

Please sign in to comment.