diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2015-03-02 19:36:57 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-03-02 19:37:04 +0000 |
commit | 10d620ff2c4770e926b693e833105e8dbbd5fa86 (patch) | |
tree | cfa05584f93ca72ffd48eb4c0175df3492ca3df5 /tools | |
parent | 9b94a5399845efc9d52ebf37e8fde320885c07c8 (diff) | |
parent | 68501b87d2891ae9bf65d400f9cd755e197fda0c (diff) | |
download | frameworks_base-10d620ff2c4770e926b693e833105e8dbbd5fa86.zip frameworks_base-10d620ff2c4770e926b693e833105e8dbbd5fa86.tar.gz frameworks_base-10d620ff2c4770e926b693e833105e8dbbd5fa86.tar.bz2 |
Merge "Better error msg for StateList/Hexadecimal Color." into lmp-dev
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; } } |