From 32ab835977f1544dd299508f66861881528004be Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 18 Jul 2015 18:12:00 -0700 Subject: Add DrawableTint.getColorRes --- .../main/java/github/daneren2005/dsub/util/DrawableTint.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/github/daneren2005/dsub/util/DrawableTint.java b/app/src/main/java/github/daneren2005/dsub/util/DrawableTint.java index f6b5d315..2da72579 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/DrawableTint.java +++ b/app/src/main/java/github/daneren2005/dsub/util/DrawableTint.java @@ -42,6 +42,13 @@ public class DrawableTint { return tintedDrawables.get(drawableRes); } + int color = getColorRes(context, colorAttr); + Drawable background = context.getResources().getDrawable(drawableRes); + background.setColorFilter(color, PorterDuff.Mode.SRC_IN); + tintedDrawables.put(drawableRes, background); + return background; + } + public static int getColorRes(Context context, @AttrRes int colorAttr) { int color; if(attrMap.containsKey(colorAttr)) { color = attrMap.get(colorAttr); @@ -53,10 +60,7 @@ public class DrawableTint { attrMap.put(colorAttr, color); } - Drawable background = context.getResources().getDrawable(drawableRes); - background.setColorFilter(color, PorterDuff.Mode.SRC_IN); - tintedDrawables.put(drawableRes, background); - return background; + return color; } public static int getDrawableRes(Context context, @AttrRes int drawableAttr) { if(attrMap.containsKey(drawableAttr)) { -- cgit v1.2.3