@Test public void testGetDrawable() throws Throwable { final Drawable unthemedDrawable = ResourcesCompat.getDrawable(mResources, R.drawable.test_drawable_red, null); TestUtils.assertAllPixelsOfColor("Unthemed drawable load", unthemedDrawable, mResources.getColor(R.color.test_red)); if (Build.VERSION.SDK_INT >= 23) { final Resources.Theme yellowTheme = mResources.newTheme(); yellowTheme.applyStyle(R.style.YellowTheme, true); final Drawable themedYellowDrawable = ResourcesCompat.getDrawable(mResources, R.drawable.themed_drawable, yellowTheme); TestUtils.assertAllPixelsOfColor("Themed yellow drawable load", themedYellowDrawable, 0xFFF0B000); final Resources.Theme lilacTheme = mResources.newTheme(); lilacTheme.applyStyle(R.style.LilacTheme, true); final Drawable themedLilacDrawable = ResourcesCompat.getDrawable(mResources, R.drawable.themed_drawable, lilacTheme); TestUtils.assertAllPixelsOfColor("Themed lilac drawable load", themedLilacDrawable, 0xFFF080F0); } }
@Nullable @SuppressWarnings("deprecation") public static Drawable getDrawable(@NonNull Resources res, @DrawableRes int id, @Nullable Theme theme) throws NotFoundException { if (SDK_INT >= 21) { return res.getDrawable(id, theme); } else { return res.getDrawable(id); } }
ResourcesCompat { @Nullable @SuppressWarnings("deprecation") public static Drawable getDrawable(@NonNull Resources res, @DrawableRes int id, @Nullable Theme theme) throws NotFoundException { if (SDK_INT >= 21) { return res.getDrawable(id, theme); } else { return res.getDrawable(id); } } }
ResourcesCompat { @Nullable @SuppressWarnings("deprecation") public static Drawable getDrawable(@NonNull Resources res, @DrawableRes int id, @Nullable Theme theme) throws NotFoundException { if (SDK_INT >= 21) { return res.getDrawable(id, theme); } else { return res.getDrawable(id); } } private  ResourcesCompat(); }
ResourcesCompat { @Nullable @SuppressWarnings("deprecation") public static Drawable getDrawable(@NonNull Resources res, @DrawableRes int id, @Nullable Theme theme) throws NotFoundException { if (SDK_INT >= 21) { return res.getDrawable(id, theme); } else { return res.getDrawable(id); } } private  ResourcesCompat(); @Nullable @SuppressWarnings("deprecation") static Drawable getDrawable(@NonNull Resources res, @DrawableRes int id,
            @Nullable Theme theme); @Nullable @SuppressWarnings("deprecation") static Drawable getDrawableForDensity(@NonNull Resources res, @DrawableRes int id,
            int density, @Nullable Theme theme); @ColorInt @SuppressWarnings("deprecation") static int getColor(@NonNull Resources res, @ColorRes int id, @Nullable Theme theme); @Nullable @SuppressWarnings("deprecation") static ColorStateList getColorStateList(@NonNull Resources res, @ColorRes int id,
            @Nullable Theme theme); @Nullable static Typeface getFont(@NonNull Context context, @FontRes int id); static void getFont(@NonNull Context context, @FontRes int id,
            @NonNull FontCallback fontCallback, @Nullable Handler handler); @RestrictTo(LIBRARY_GROUP) static Typeface getFont(@NonNull Context context, @FontRes int id, TypedValue value,
            int style, @Nullable FontCallback fontCallback); }
ResourcesCompat { @Nullable @SuppressWarnings("deprecation") public static Drawable getDrawable(@NonNull Resources res, @DrawableRes int id, @Nullable Theme theme) throws NotFoundException { if (SDK_INT >= 21) { return res.getDrawable(id, theme); } else { return res.getDrawable(id); } } private  ResourcesCompat(); @Nullable @SuppressWarnings("deprecation") static Drawable getDrawable(@NonNull Resources res, @DrawableRes int id,
            @Nullable Theme theme); @Nullable @SuppressWarnings("deprecation") static Drawable getDrawableForDensity(@NonNull Resources res, @DrawableRes int id,
            int density, @Nullable Theme theme); @ColorInt @SuppressWarnings("deprecation") static int getColor(@NonNull Resources res, @ColorRes int id, @Nullable Theme theme); @Nullable @SuppressWarnings("deprecation") static ColorStateList getColorStateList(@NonNull Resources res, @ColorRes int id,
            @Nullable Theme theme); @Nullable static Typeface getFont(@NonNull Context context, @FontRes int id); static void getFont(@NonNull Context context, @FontRes int id,
            @NonNull FontCallback fontCallback, @Nullable Handler handler); @RestrictTo(LIBRARY_GROUP) static Typeface getFont(@NonNull Context context, @FontRes int id, TypedValue value,
            int style, @Nullable FontCallback fontCallback);  }