Methods Summary |
---|
public void | addResourceValue(java.lang.String resType, com.android.layoutlib.utils.ResourceValue value)Adds a resource item to the list
ResourceType type = ResourceType.getEnum(resType);
if (type != null) {
HashMap<String, ResourceValue> list = mResourceItems.get(type);
// if the list does not exist, create it.
if (list == null) {
list = new HashMap<String, ResourceValue>();
mResourceItems.put(type, list);
} else {
// look for a possible value already existing.
ResourceValue oldValue = list.get(value.getName());
if (oldValue != null) {
oldValue.replaceWith(value);
return;
}
}
// empty list or no match found? add the given resource
list.put(value.getName(), value);
}
|
public com.android.ide.eclipse.common.resources.ResourceType[] | getResourceTypes()
update();
Set<ResourceType> keys = mResourceItems.keySet();
return keys.toArray(new ResourceType[keys.size()]);
|
public java.util.Collection | getResources(com.android.ide.eclipse.common.resources.ResourceType type, ProjectResources projectResources)
update();
HashMap<String, ResourceValue> list = mResourceItems.get(type);
ArrayList<ProjectResourceItem> items = new ArrayList<ProjectResourceItem>();
if (list != null) {
Collection<ResourceValue> values = list.values();
for (ResourceValue res : values) {
ProjectResourceItem item = projectResources.findResourceItem(type, res.getName());
if (item == null) {
if (type == ResourceType.ID) {
item = new IdResourceItem(res.getName(), false /* isDeclaredInline */);
} else {
item = new ConfigurableResourceItem(res.getName());
}
items.add(item);
}
item.add(this);
}
}
return items;
|
public com.android.layoutlib.api.IResourceValue | getValue(com.android.ide.eclipse.common.resources.ResourceType type, java.lang.String name)
update();
// get the list for the given type
HashMap<String, ResourceValue> list = mResourceItems.get(type);
if (list != null) {
return list.get(name);
}
return null;
|
public boolean | hasResources(com.android.ide.eclipse.common.resources.ResourceType type)
update();
HashMap<String, ResourceValue> list = mResourceItems.get(type);
return (list != null && list.size() > 0);
|
private void | parseFile()Parses the file and creates a list of {@link ResourceType}.
try {
SAXParser parser = sParserFactory.newSAXParser();
parser.parse(getFile().getContents(), new ValueResourceParser(this, isFramework()));
} catch (ParserConfigurationException e) {
} catch (SAXException e) {
} catch (IOException e) {
} catch (CoreException e) {
}
|
private void | update()Updates the Resource items if necessary.
if (isTouched() == true) {
// reset current content.
mResourceItems.clear();
// need to parse the file and find the content.
parseFile();
resetTouch();
}
|