diff options
author | Xavier Ducrohet <xav@android.com> | 2011-01-27 18:05:56 -0800 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2011-01-28 12:42:05 -0800 |
commit | 3bd45f0b16f5ebfafd8080a0f17f71d85c9840ed (patch) | |
tree | 72a0de0eda8b085d7038a3987ef23d1a05000654 /ide_common/src/com/android/ide/common/resources/ValueResourceParser.java | |
parent | 40826f2c5a850a1c0b74ec6193181383175f20cf (diff) | |
download | sdk-3bd45f0b16f5ebfafd8080a0f17f71d85c9840ed.zip sdk-3bd45f0b16f5ebfafd8080a0f17f71d85c9840ed.tar.gz sdk-3bd45f0b16f5ebfafd8080a0f17f71d85c9840ed.tar.bz2 |
Change APIs using String instead of ResourceType.
Move ResourceType into resources.jar so that it's accessible
to layoutlib.jar
This is cleaner and allows us to us more efficient EnumMap objects.
Change-Id: If11cbc69ae3ca8bd6c96e6d0ef402570a07af16f
Diffstat (limited to 'ide_common/src/com/android/ide/common/resources/ValueResourceParser.java')
-rw-r--r-- | ide_common/src/com/android/ide/common/resources/ValueResourceParser.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/ide_common/src/com/android/ide/common/resources/ValueResourceParser.java b/ide_common/src/com/android/ide/common/resources/ValueResourceParser.java index 2e4cf8e..cda6587 100644 --- a/ide_common/src/com/android/ide/common/resources/ValueResourceParser.java +++ b/ide_common/src/com/android/ide/common/resources/ValueResourceParser.java @@ -18,6 +18,7 @@ package com.android.ide.common.resources; import com.android.ide.common.rendering.api.ResourceValue; import com.android.ide.common.rendering.api.StyleResourceValue; +import com.android.resources.ResourceType; import org.xml.sax.Attributes; import org.xml.sax.SAXException; @@ -35,15 +36,11 @@ public final class ValueResourceParser extends DefaultHandler { private final static String ATTR_TYPE = "type"; private final static String ATTR_PARENT = "parent"; - // Resource type definition - private final static String RES_STYLE = "style"; - private final static String RES_ATTR = "attr"; - private final static String DEFAULT_NS_PREFIX = "android:"; private final static int DEFAULT_NS_PREFIX_LEN = DEFAULT_NS_PREFIX.length(); public interface IValueResourceRepository { - void addResourceValue(String resType, ResourceValue value); + void addResourceValue(ResourceType type, ResourceValue value); } private boolean inResources = false; @@ -87,24 +84,27 @@ public final class ValueResourceParser extends DefaultHandler { inResources = true; } } else if (mDepth == 2 && inResources == true) { - String type; + String typeValue; // if the node is <item>, we get the type from the attribute "type" if (NODE_ITEM.equals(qName)) { - type = attributes.getValue(ATTR_TYPE); + typeValue = attributes.getValue(ATTR_TYPE); } else { // the type is the name of the node. - type = qName; + typeValue = qName; } + ResourceType type = ResourceType.getEnum(typeValue); + if (type != null) { - if (RES_ATTR.equals(type) == false) { + if (type != ResourceType.ATTR) { // get the resource name String name = attributes.getValue(ATTR_NAME); if (name != null) { - if (RES_STYLE.equals(type)) { + if (type == ResourceType.STYLE) { String parent = attributes.getValue(ATTR_PARENT); - mCurrentStyle = new StyleResourceValue(type, name, parent, mIsFramework); + mCurrentStyle = new StyleResourceValue(type, name, parent, + mIsFramework); mRepository.addResourceValue(type, mCurrentStyle); } else { mCurrentValue = new ResourceValue(type, name, mIsFramework); |