Lines Matching refs:drawable

23 import android.graphics.drawable.Drawable;
24 import android.graphics.drawable.DrawableContainer;
25 import android.graphics.drawable.GradientDrawable;
26 import android.graphics.drawable.InsetDrawable;
27 import android.graphics.drawable.LayerDrawable;
28 import android.graphics.drawable.ScaleDrawable;
32 import android.support.v4.graphics.drawable.DrawableCompat;
48 = "android.graphics.drawable.VectorDrawable";
66 public static Rect getOpticalBounds(Drawable drawable) {
70 // the wrapped drawable.
71 drawable = DrawableCompat.unwrap(drawable);
73 final Method getOpticalInsetsMethod = drawable.getClass()
75 final Object insets = getOpticalInsetsMethod.invoke(drawable);
78 // If the drawable has some optical insets, let's copy them into a Rect
111 * Attempt the fix any issues in the given drawable, usually caused by platform bugs in the
115 static void fixDrawable(@NonNull final Drawable drawable) {
117 && VECTOR_DRAWABLE_CLAZZ_NAME.equals(drawable.getClass().getName())) {
118 fixVectorDrawableTinting(drawable);
123 * Some drawable implementations have problems with mutation. This method returns false if
124 * there is a known issue in the given drawable's implementation.
126 public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
127 if (Build.VERSION.SDK_INT < 15 && drawable instanceof InsetDrawable) {
129 } else if (Build.VERSION.SDK_INT < 15 && drawable instanceof GradientDrawable) {
133 } else if (Build.VERSION.SDK_INT < 17 && drawable instanceof LayerDrawable) {
137 if (drawable instanceof DrawableContainer) {
139 final Drawable.ConstantState state = drawable.getConstantState();
149 } else if (drawable instanceof android.support.v4.graphics.drawable.DrawableWrapper) {
151 ((android.support.v4.graphics.drawable.DrawableWrapper) drawable)
153 } else if (drawable instanceof android.support.v7.graphics.drawable.DrawableWrapper) {
155 ((android.support.v7.graphics.drawable.DrawableWrapper) drawable)
157 } else if (drawable instanceof ScaleDrawable) {
158 return canSafelyMutateDrawable(((ScaleDrawable) drawable).getDrawable());
168 private static void fixVectorDrawableTinting(final Drawable drawable) {
169 final int[] originalState = drawable.getState();
171 // The drawable doesn't have a state, so set it to be checked
172 drawable.setState(ThemeUtils.CHECKED_STATE_SET);
174 // Else the drawable does have a state, so clear it
175 drawable.setState(ThemeUtils.EMPTY_STATE_SET);
178 drawable.setState(originalState);