From 4d8e078c7c9c9f8407ebc7e88673e53b67723e18 Mon Sep 17 00:00:00 2001 From: Deepanshu Gupta Date: Wed, 20 May 2015 18:25:58 -0700 Subject: [PATCH] Fix overrides for BridgeResources. New method overloads have been introduces in android.content.Resources. Change BridgeResources to overrides the appropriate ones. Also, fix the implementation to the new behaviour. Change-Id: I7b83b329f04286512f223c0fafc3f989f1b9a244 --- .../src/android/content/res/BridgeResources.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java b/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java index 2c2c6723f981f..fdb6e752d1897 100644 --- a/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java +++ b/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java @@ -169,7 +169,7 @@ public final class BridgeResources extends Resources { } @Override - public int getColor(int id) throws NotFoundException { + public int getColor(int id, Theme theme) throws NotFoundException { Pair value = getResourceValue(id, mPlatformResourceFlag); if (value != null) { @@ -192,22 +192,21 @@ public final class BridgeResources extends Resources { } } - // id was not found or not resolved. Throw a NotFoundException. - throwException(id); - - // this is not used since the method above always throws - return 0; + // Suppress possible NPE. getColorStateList will never return null, it will instead + // throw an exception, but intelliJ can't figure that out + //noinspection ConstantConditions + return getColorStateList(id, theme).getDefaultColor(); } @Override - public ColorStateList getColorStateList(int id) throws NotFoundException { + public ColorStateList getColorStateList(int id, Theme theme) throws NotFoundException { Pair resValue = getResourceValue(id, mPlatformResourceFlag); if (resValue != null) { ColorStateList stateList = ResourceHelper.getColorStateList(resValue.getSecond(), mContext); if (stateList != null) { - return stateList; + return stateList.obtainForTheme(theme); } }