diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2015-02-23 11:52:10 -0800 |
---|---|---|
committer | Deepanshu Gupta <deepanshu@google.com> | 2015-02-23 12:00:38 -0800 |
commit | 68501b87d2891ae9bf65d400f9cd755e197fda0c (patch) | |
tree | 43f9d89bbcd5626b75c1ad1b34b143bef626e3d5 /tools | |
parent | e0f61e1c516be37125f16f1f0899ea6244d094c2 (diff) | |
download | frameworks_base-68501b87d2891ae9bf65d400f9cd755e197fda0c.zip frameworks_base-68501b87d2891ae9bf65d400f9cd755e197fda0c.tar.gz frameworks_base-68501b87d2891ae9bf65d400f9cd755e197fda0c.tar.bz2 |
Better error msg for StateList/Hexadecimal Color.
Throw a better error message when resolving a hexadecimal color value
but the user gave a Color State List. The two are easy to confuse since
the only way to distinguish between the two is to look at the
definition.
Bug: http://b.android.com/70110
Change-Id: Ic78962bd0674a92296a0fdd0de184cfe4d85a8e4
Diffstat (limited to 'tools')
-rw-r--r-- | tools/layoutlib/bridge/src/android/content/res/BridgeResources.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java b/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java index 66126af..96ca250 100644 --- a/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java +++ b/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java @@ -178,11 +178,21 @@ public final class BridgeResources extends Resources { Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag); if (value != null) { + ResourceValue resourceValue = value.getSecond(); try { - return ResourceHelper.getColor(value.getSecond().getValue()); + return ResourceHelper.getColor(resourceValue.getValue()); } catch (NumberFormatException e) { - Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, e.getMessage(), e, - null /*data*/); + // Check if the value passed is a file. If it is, mostly likely, user is referencing + // a color state list from a place where they should reference only a pure color. + String message; + if (new File(resourceValue.getValue()).isFile()) { + String resource = (resourceValue.isFramework() ? "@android:" : "@") + "color/" + + resourceValue.getName(); + message = "Hexadecimal color expected, found Color State List for " + resource; + } else { + message = e.getMessage(); + } + Bridge.getLog().error(LayoutLog.TAG_RESOURCES_FORMAT, message, e, null); return 0; } } |