本文整理汇总了Java中com.android.resources.ResourceType.getEnum方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceType.getEnum方法的具体用法?Java ResourceType.getEnum怎么用?Java ResourceType.getEnum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.resources.ResourceType
的用法示例。
在下文中一共展示了ResourceType.getEnum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getType
import com.android.resources.ResourceType; //导入方法依赖的package包/类
@Nullable
private ResourceType getType(String qName, NamedNodeMap attributes) {
String typeValue;
// if the node is <item>, we get the type from the attribute "type"
if (SdkConstants.TAG_ITEM.equals(qName)) {
typeValue = getAttributeValue(attributes, ATTR_TYPE);
} else {
// the type is the name of the node.
typeValue = qName;
}
return ResourceType.getEnum(typeValue);
}
示例2: getType
import com.android.resources.ResourceType; //导入方法依赖的package包/类
/**
* Returns the type of the ResourceItem based on a node's attributes.
* @param node the node
* @return the ResourceType or null if it could not be inferred.
*/
static ResourceType getType(@NonNull Node node, @Nullable File from) {
String nodeName = node.getLocalName();
String typeString = null;
if (TAG_ITEM.equals(nodeName)) {
Attr attribute = (Attr) node.getAttributes().getNamedItemNS(null, ATTR_TYPE);
if (attribute != null) {
typeString = attribute.getValue();
}
} else if (TAG_EAT_COMMENT.equals(nodeName) || TAG_SKIP.equals(nodeName)) {
return null;
} else {
// the type is the name of the node.
typeString = nodeName;
}
if (typeString != null) {
ResourceType type = ResourceType.getEnum(typeString);
if (type != null) {
return type;
}
if (from != null) {
throw new RuntimeException(String.format("Unsupported type '%s' in file %s", typeString, from));
}
throw new RuntimeException(String.format("Unsupported type '%s'", typeString));
}
if (from != null) {
throw new RuntimeException(String.format("Unsupported node '%s' in file %s", nodeName, from));
}
throw new RuntimeException(String.format("Unsupported node '%s'", nodeName));
}
示例3: getType
import com.android.resources.ResourceType; //导入方法依赖的package包/类
private ResourceType getType(String qName, Attributes attributes) {
String typeValue;
// if the node is <item>, we get the type from the attribute "type"
if (NODE_ITEM.equals(qName)) {
typeValue = attributes.getValue(ATTR_TYPE);
} else {
// the type is the name of the node.
typeValue = qName;
}
ResourceType type = ResourceType.getEnum(typeValue);
return type;
}