From b5194e4f103c866fc2c75dfdc881ae5f6cfb0011 Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Fri, 24 Jun 2011 11:42:32 -0700 Subject: Fix value parser to handle attr values not in declare-styleable. Also change the layoutlib sample code to properly get the list of framework attr flag/enum values. Change-Id: Ie0bf126a0fab574d94d0f86b7b2f8581cf4eaae3 --- .../api/DeclareStyleableResourceValue.java | 33 ++++++++-------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'layoutlib_api/src/com/android/ide/common/rendering/api/DeclareStyleableResourceValue.java') diff --git a/layoutlib_api/src/com/android/ide/common/rendering/api/DeclareStyleableResourceValue.java b/layoutlib_api/src/com/android/ide/common/rendering/api/DeclareStyleableResourceValue.java index 0699766..45679b2 100644 --- a/layoutlib_api/src/com/android/ide/common/rendering/api/DeclareStyleableResourceValue.java +++ b/layoutlib_api/src/com/android/ide/common/rendering/api/DeclareStyleableResourceValue.java @@ -30,11 +30,10 @@ import java.util.Map; */ public class DeclareStyleableResourceValue extends ResourceValue { - private Map> mEnumMap; + private Map mAttrMap; public DeclareStyleableResourceValue(ResourceType type, String name, boolean isFramework) { super(type, name, isFramework); - } /** @@ -43,33 +42,25 @@ public class DeclareStyleableResourceValue extends ResourceValue { * @return the map of (name, integer) values. */ public Map getAttributeValues(String name) { - if (mEnumMap != null) { - return mEnumMap.get(name); + if (mAttrMap != null) { + AttrResourceValue attr = mAttrMap.get(name); + if (attr != null) { + return attr.getAttributeValues(); + } } return null; } - public Map> getAllAttributes() { - return mEnumMap; + public Map getAllAttributes() { + return mAttrMap; } - public void addValue(String attribute, String name, Integer value) { - Map map; - - if (mEnumMap == null) { - mEnumMap = new HashMap>(); - - map = new HashMap(); - mEnumMap.put(attribute, map); - } else { - map = mEnumMap.get(attribute); - if (map == null) { - map = new HashMap(); - mEnumMap.put(attribute, map); - } + public void addValue(AttrResourceValue attr) { + if (mAttrMap == null) { + mAttrMap = new HashMap(); } - map.put(name, value); + mAttrMap.put(attr.getName(), attr); } } -- cgit v1.1