Lines Matching defs:drawable

21 import android.graphics.drawable.Drawable;
22 import android.graphics.drawable.DrawableContainer;
23 import android.graphics.drawable.GradientDrawable;
24 import android.graphics.drawable.InsetDrawable;
25 import android.graphics.drawable.LayerDrawable;
26 import android.graphics.drawable.ScaleDrawable;
27 import android.graphics.drawable.StateListDrawable;
31 import android.support.v4.graphics.drawable.DrawableCompat;
49 = "android.graphics.drawable.VectorDrawable";
67 public static Rect getOpticalBounds(Drawable drawable) {
71 // the wrapped drawable.
72 drawable = DrawableCompat.unwrap(drawable);
74 final Method getOpticalInsetsMethod = drawable.getClass()
76 final Object insets = getOpticalInsetsMethod.invoke(drawable);
79 // If the drawable has some optical insets, let's copy them into a Rect
112 * Attempt the fix any issues in the given drawable, usually caused by platform bugs in the
116 static void fixDrawable(@NonNull final Drawable drawable) {
118 && VECTOR_DRAWABLE_CLAZZ_NAME.equals(drawable.getClass().getName())) {
119 fixVectorDrawableTinting(drawable);
124 * Some drawable implementations have problems with mutation. This method returns false if
125 * there is a known issue in the given drawable's implementation.
127 public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
128 if (Build.VERSION.SDK_INT < 15 && drawable instanceof InsetDrawable) {
130 } else if (Build.VERSION.SDK_INT < 15 && drawable instanceof GradientDrawable) {
134 } else if (Build.VERSION.SDK_INT < 17 && drawable instanceof LayerDrawable) {
138 if (drawable instanceof DrawableContainer) {
140 final Drawable.ConstantState state = drawable.getConstantState();
150 } else if (drawable instanceof android.support.v4.graphics.drawable.DrawableWrapper) {
152 ((android.support.v4.graphics.drawable.DrawableWrapper) drawable)
154 } else if (drawable instanceof android.support.v7.graphics.drawable.DrawableWrapper) {
156 ((android.support.v7.graphics.drawable.DrawableWrapper) drawable)
158 } else if (drawable instanceof ScaleDrawable) {
159 return canSafelyMutateDrawable(((ScaleDrawable) drawable).getDrawable());
169 private static void fixVectorDrawableTinting(final Drawable drawable) {
170 final int[] originalState = drawable.getState();
172 // The drawable doesn't have a state, so set it to be checked
173 drawable.setState(ThemeUtils.CHECKED_STATE_SET);
175 // Else the drawable does have a state, so clear it
176 drawable.setState(ThemeUtils.EMPTY_STATE_SET);
179 drawable.setState(originalState);