From 51c4b1e6f301d1eff1f747157ec0a7a3bceda09d Mon Sep 17 00:00:00 2001 From: Leonardo Taehwan Kim Date: Tue, 15 Mar 2016 12:12:00 +0900 Subject: [PATCH] Fix issue #37 --- .../finestwebview/FinestWebViewActivity.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/com/thefinestartist/finestwebview/FinestWebViewActivity.java b/library/src/main/java/com/thefinestartist/finestwebview/FinestWebViewActivity.java index aeffd32..8e9cace 100644 --- a/library/src/main/java/com/thefinestartist/finestwebview/FinestWebViewActivity.java +++ b/library/src/main/java/com/thefinestartist/finestwebview/FinestWebViewActivity.java @@ -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; @@ -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 @@ -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