From 3790c6cd6ccedda49d776664c4bb444fecf6b98b Mon Sep 17 00:00:00 2001 From: aurimas Date: Sat, 21 Mar 2015 00:37:38 -0700 Subject: Add an getDrawable to ApiCompatibilityUtils getDrawable(int) was deprecated in Android API 22 so we need to add a wrapper around it. BUG=440601 Review URL: https://codereview.chromium.org/1022683002 Cr-Commit-Position: refs/heads/master@{#321681} --- .../java/src/org/chromium/base/ApiCompatibilityUtils.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'base/android') diff --git a/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java b/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java index 59d42c1..71b79b1 100644 --- a/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java +++ b/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java @@ -14,6 +14,8 @@ import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.res.Configuration; +import android.content.res.Resources; +import android.content.res.Resources.NotFoundException; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.drawable.Drawable; @@ -482,6 +484,18 @@ public class ApiCompatibilityUtils { } /** + * @see android.content.res.Resources#getDrawable(int id). + */ + @SuppressWarnings("deprecation") + public static Drawable getDrawable(Resources res, int id) throws NotFoundException { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + return res.getDrawable(id, null); + } else { + return res.getDrawable(id); + } + } + + /** * @see android.view.View#announceForAccessibility(CharSequence text) */ public static void announceForAccessibility(View view, CharSequence text) { -- cgit v1.1