Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1816)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java

Issue 614463002: [Android] Fall back to unthemed resources when loading handle resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Keep using app context Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java b/content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java
index 25fc8b62b5847dc1ab90c64cb0eeb0fab2d2a607..841a7081d434cd7e43f15b6ee46bd613b2a1b6c7 100644
--- a/content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java
+++ b/content/public/android/java/src/org/chromium/content/browser/input/HandleViewResources.java
@@ -47,6 +47,15 @@ public class HandleViewResources {
private static Drawable getHandleDrawable(Context context, final int[] attrs) {
TypedArray a = context.getTheme().obtainStyledAttributes(attrs);
Drawable drawable = a.getDrawable(0);
+ if (drawable == null) {
+ // If themed resource lookup fails, fall back to using the Context's
+ // resources for attribute lookup.
+ try {
+ drawable = context.getResources().getDrawable(a.getResourceId(0, 0));
+ } catch (Resources.NotFoundException e) {
+ // The caller should handle the null return case appropriately.
+ }
+ }
a.recycle();
return drawable;
}
@@ -62,9 +71,16 @@ public class HandleViewResources {
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = false;
options.inPreferredConfig = config;
- final Bitmap bitmap = BitmapFactory.decodeResource(res, resId, options);
+ Bitmap bitmap = BitmapFactory.decodeResource(res, resId, options);
if (bitmap != null) return bitmap;
+ // If themed resource lookup fails, fall back to using the Context's
+ // resources for attribute lookup.
+ if (res != context.getResources()) {
+ bitmap = BitmapFactory.decodeResource(context.getResources(), resId, options);
+ if (bitmap != null) return bitmap;
+ }
+
Drawable drawable = getHandleDrawable(context, attrs);
assert drawable != null;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698