diff options
author | aurimas <aurimas@chromium.org> | 2015-03-21 00:37:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-21 07:38:24 +0000 |
commit | 3790c6cd6ccedda49d776664c4bb444fecf6b98b (patch) | |
tree | a87fd0e5ac6fdbe921a173e99ff351dbcc6634c9 /base/android | |
parent | 9e9ddf88e048a978d6eb3721f4b7bbb50ad5b052 (diff) | |
download | chromium_src-3790c6cd6ccedda49d776664c4bb444fecf6b98b.zip chromium_src-3790c6cd6ccedda49d776664c4bb444fecf6b98b.tar.gz chromium_src-3790c6cd6ccedda49d776664c4bb444fecf6b98b.tar.bz2 |
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}
Diffstat (limited to 'base/android')
-rw-r--r-- | base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java | 14 |
1 files changed, 14 insertions, 0 deletions
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) { |