diff options
author | Deepanshu Gupta <deepanshu@google.com> | 2015-08-04 11:57:10 -0700 |
---|---|---|
committer | Deepanshu Gupta <deepanshu@google.com> | 2015-08-25 12:06:58 -0700 |
commit | da687918e13010d56e3d067e0ef477165cf38e10 (patch) | |
tree | 5bea0911a8f74920d0a7fbf80aabdbf610532912 /tools/layoutlib | |
parent | 8c674fda8939c2d30f85e0341b70d9f3edd04d6c (diff) | |
download | frameworks_base-da687918e13010d56e3d067e0ef477165cf38e10.zip frameworks_base-da687918e13010d56e3d067e0ef477165cf38e10.tar.gz frameworks_base-da687918e13010d56e3d067e0ef477165cf38e10.tar.bz2 |
Make getInt in BridgeTypedArray accept empty String. [DO NOT MERGE]
The XML editor already warns about the empty strings in places where an
int value is required. There's no need to show another warning for it in
the rendering panel. Also, the rendering might have also failed when the
empty string is encountered. Try an continue the rendering, because no
rendering state is really bad.
Change-Id: I85106f37e4462f237e85f0b065b4ce8a4bfabf4d
(cherry picked from commit 0437cac76c24dc6cac7b530e6d80f789565550ec)
Diffstat (limited to 'tools/layoutlib')
-rw-r--r-- | tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java index d54e3d7..b8fd1ca 100644 --- a/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java +++ b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java @@ -239,15 +239,12 @@ public final class BridgeTypedArray extends TypedArray { public int getInt(int index, int defValue) { String s = getString(index); try { - if (s != null) { - return convertValueToInt(s, defValue); - } + return convertValueToInt(s, defValue); } catch (NumberFormatException e) { Bridge.getLog().warning(LayoutLog.TAG_RESOURCES_FORMAT, String.format("\"%1$s\" in attribute \"%2$s\" is not a valid integer", s, mNames[index]), null); - return defValue; } return defValue; } @@ -948,7 +945,7 @@ public final class BridgeTypedArray extends TypedArray { * "XXXXXXXX" > 80000000. */ private static int convertValueToInt(@Nullable String charSeq, int defValue) { - if (null == charSeq) + if (null == charSeq || charSeq.isEmpty()) return defValue; int sign = 1; |