package cn.ycoder.android.library.tool;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.support.annotation.ColorInt;
import android.support.annotation.DrawableRes;
import android.support.v4.graphics.drawable.DrawableCompat;

/**
 * @author 启研
 * @created at 2017/4/19 11:30
 */

public class ImageUtils {
    public static Drawable tintDrawable(Drawable drawable, ColorStateList colorStateList) {
        Drawable drawable1 = DrawableCompat.wrap(drawable);
        DrawableCompat.setTintList(drawable1, colorStateList);
        return drawable1;
    }

    public static Drawable tintDrawable(Drawable drawable, @ColorInt int color) {
        Drawable drawable1 = DrawableCompat.wrap(drawable);
        DrawableCompat.setTintList(drawable1, ColorStateList.valueOf(color));
        return drawable1;
    }

    public static int getDrawableResource(String drawableName,@DrawableRes int defaultRes) {
        Context ctx = Utils.getContext();
        int resId = ctx.getResources().getIdentifier(drawableName, "drawable", ctx.getPackageName());
        return resId;
    }
}

@@ -384,18 +384,17 @@
 Utils %7B%0A
-  
+%0A
   public
@@ -471,28 +471,24 @@
 tateList) %7B%0A
-    
     Drawable
@@ -523,36 +523,32 @@
 wrap(drawable);%0A
-    
     DrawableComp
@@ -590,28 +590,24 @@
 eList);%0A    
-   
- 
 return drawa
@@ -608,33 +608,29 @@
  drawable1;%0A
-  
   %7D%0A%0A
-  
   public sta
@@ -697,28 +697,24 @@
 olor) %7B%0A    
-  
-  
 Drawable dra
@@ -753,20 +753,16 @@
 wable);%0A
-    
     Draw
@@ -823,28 +823,24 @@
 Of(color));%0A
-    
     return d
@@ -853,19 +853,15 @@
 e1;%0A
-  
   %7D%0A%0A  
- 
- 
 publ
@@ -914,16 +914,17 @@
 bleName,
+ 
 @Drawabl
@@ -950,20 +950,16 @@
 ) %7B%0A    
-  
-  
 Context 
@@ -982,24 +982,32 @@
 ontext();%0A  
+  try %7B%0A
       int re
@@ -1100,18 +1100,16 @@
 ;%0A      
-  
 return r
@@ -1119,11 +1119,68 @@
 d;%0A    %7D
+ catch (Exception e) %7B%0A      return defaultRes;%0A    %7D%0A  %7D
 %0A%7D%0A

修正：增加清理Aroute历史访问