|
|
|
@ -1,5 +1,7 @@
@@ -1,5 +1,7 @@
|
|
|
|
|
package acr.browser.lightning.utils; |
|
|
|
|
|
|
|
|
|
import android.content.Context; |
|
|
|
|
import android.content.res.TypedArray; |
|
|
|
|
import android.graphics.Bitmap; |
|
|
|
|
import android.graphics.Canvas; |
|
|
|
|
import android.graphics.Paint; |
|
|
|
@ -7,6 +9,13 @@ import android.graphics.PorterDuff;
@@ -7,6 +9,13 @@ import android.graphics.PorterDuff;
|
|
|
|
|
import android.graphics.PorterDuffXfermode; |
|
|
|
|
import android.graphics.RectF; |
|
|
|
|
import android.graphics.Typeface; |
|
|
|
|
import android.graphics.drawable.Drawable; |
|
|
|
|
import android.os.Build; |
|
|
|
|
import android.support.annotation.AttrRes; |
|
|
|
|
import android.support.annotation.NonNull; |
|
|
|
|
import android.support.annotation.Nullable; |
|
|
|
|
import android.util.TypedValue; |
|
|
|
|
import android.view.View; |
|
|
|
|
|
|
|
|
|
public class DrawableUtils { |
|
|
|
|
|
|
|
|
@ -71,4 +80,23 @@ public class DrawableUtils {
@@ -71,4 +80,23 @@ public class DrawableUtils {
|
|
|
|
|
(startB + (int) (fraction * (endB - startB))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Drawable resolveDrawableAttribute(@NonNull Context context, @AttrRes int res) { |
|
|
|
|
int[] attribute = new int[]{res}; |
|
|
|
|
int indexOfAttrTextSize = 0; |
|
|
|
|
TypedValue typedValue = new TypedValue(); |
|
|
|
|
TypedArray a = context.obtainStyledAttributes(typedValue.data, attribute); |
|
|
|
|
Drawable drawable = a.getDrawable(indexOfAttrTextSize); |
|
|
|
|
a.recycle(); |
|
|
|
|
return drawable; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void setBackground(@NonNull View view, @Nullable Drawable drawable) { |
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { |
|
|
|
|
view.setBackground(drawable); |
|
|
|
|
} else { |
|
|
|
|
//noinspection deprecation
|
|
|
|
|
view.setBackgroundDrawable(drawable); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|