use of android.support.annotation.XmlRes in project robotcode by OutoftheBoxFTC.
the class RobotConfigFileManager method getXMLFiles.
/**
* Gets the list of files from the Configuration File directory, and populates the global list
* used by the fileSpinner. Note that this should only ever be executed on the robot controller,
* not the driver station, as the robot controller is the authoritative source of configurations.
*/
public ArrayList<RobotConfigFile> getXMLFiles() {
File robotDir = AppUtil.CONFIG_FILES_DIR;
File[] configFiles = robotDir.listFiles();
ArrayList<RobotConfigFile> fileList = new ArrayList<RobotConfigFile>();
for (File f : configFiles) {
if (f.isFile()) {
String name = f.getName();
Pattern pattern = Pattern.compile("(?i).xml");
if (pattern.matcher(name).find()) {
String nameNoExt = stripFileNameExtension(name);
fileList.add(new RobotConfigFile(this, nameNoExt));
}
}
}
/*
* Pull the cached list of filtered resources
*/
for (@XmlRes int id : getXmlResourceIds()) {
/**
* With file-based configurations, the name of the configuration always
* matches the name of the file in which the XML is stored. And by default,
* the same is similarly true of resource-based configurations. Unfortunately,
* however, resource names have significant syntax restrictions on them. To
* work around this limitation, the name of a resource-based configuration
* may optionally be taken from the "name" attribute of the root element.
*/
XmlResourceParser xpp = resources.getXml(id);
String name = RobotConfigResFilter.getRootAttribute(xpp, RobotConfigResFilter.robotConfigRootTag, "name", resources.getResourceEntryName(id));
// Avoid duplicate names
RobotConfigFile configFile = new RobotConfigFile(name, id);
if (!configFile.containedIn(fileList)) {
fileList.add(configFile);
}
}
return fileList;
}
use of android.support.annotation.XmlRes in project robotcode by OutoftheBoxFTC.
the class RobotConfigFileManager method getXMLTemplates.
public ArrayList<RobotConfigFile> getXMLTemplates() {
ArrayList<RobotConfigFile> templateList = new ArrayList<RobotConfigFile>();
for (@XmlRes int id : getXmlResourceTemplateIds()) {
/**
* @see #getXMLFiles()
*/
XmlResourceParser xpp = resources.getXml(id);
String name = RobotConfigResFilter.getRootAttribute(xpp, RobotConfigResFilter.robotConfigRootTag, "name", resources.getResourceEntryName(id));
// Avoid duplicate names
RobotConfigFile configFile = new RobotConfigFile(name, id);
if (!configFile.containedIn(templateList)) {
templateList.add(configFile);
}
}
return templateList;
}
Aggregations