use of org.xmlpull.v1.XmlPullParserFactory in project android_frameworks_base by ResurrectionRemix.
the class TtmlRenderingWidget method loadParser.
private void loadParser(String ttmlFragment) throws XmlPullParserException {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(false);
mParser = factory.newPullParser();
StringReader in = new StringReader(ttmlFragment);
mParser.setInput(in);
}
use of org.xmlpull.v1.XmlPullParserFactory in project android_frameworks_base by ResurrectionRemix.
the class IconPackHelper method getIconPackResources.
private Map<String, String> getIconPackResources(Context context, String packageName) {
if (TextUtils.isEmpty(packageName)) {
return null;
}
Resources res = null;
try {
res = context.getPackageManager().getResourcesForApplication(packageName);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return null;
}
XmlPullParser parser = null;
InputStream inputStream = null;
Map<String, String> iconPackResources = new HashMap<String, String>();
try {
inputStream = res.getAssets().open("appfilter.xml");
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
parser = factory.newPullParser();
parser.setInput(inputStream, "UTF-8");
} catch (Exception e) {
// Catch any exception since we want to fall back to parsing the xml/
// resource in all cases
int resId = res.getIdentifier("appfilter", "xml", packageName);
if (resId != 0) {
parser = res.getXml(resId);
}
}
if (parser != null) {
try {
loadResourcesFromXmlParser(parser, iconPackResources);
return iconPackResources;
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// Cleanup resources
if (parser instanceof XmlResourceParser) {
((XmlResourceParser) parser).close();
}
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
}
}
}
}
// Application uses a different theme format (most likely launcher pro)
int arrayId = res.getIdentifier("theme_iconpack", "array", packageName);
if (arrayId == 0) {
arrayId = res.getIdentifier("icon_pack", "array", packageName);
}
if (arrayId != 0) {
String[] iconPack = res.getStringArray(arrayId);
for (String entry : iconPack) {
if (TextUtils.isEmpty(entry)) {
continue;
}
String icon = entry.toLowerCase();
entry = entry.replaceAll("_", ".");
iconPackResources.put(entry, icon);
int activityIndex = entry.lastIndexOf(".");
if (activityIndex <= 0 || activityIndex == entry.length() - 1) {
continue;
}
String iconPackage = entry.substring(0, activityIndex);
if (TextUtils.isEmpty(iconPackage)) {
continue;
}
iconPackResources.put(iconPackage, icon);
String iconActivity = entry.substring(activityIndex + 1);
if (TextUtils.isEmpty(iconActivity)) {
continue;
}
iconPackResources.put(iconPackage + "." + iconActivity, icon);
}
} else {
loadApplicationResources(context, iconPackResources, packageName);
}
return iconPackResources;
}
use of org.xmlpull.v1.XmlPullParserFactory in project Lightning-Browser by anthonycr.
the class GoogleSuggestionsModel method getParser.
@NonNull
private static synchronized XmlPullParser getParser() throws XmlPullParserException {
if (sXpp == null) {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
sXpp = factory.newPullParser();
}
return sXpp;
}
use of org.xmlpull.v1.XmlPullParserFactory in project android_frameworks_base by crdroidandroid.
the class TtmlRenderingWidget method loadParser.
private void loadParser(String ttmlFragment) throws XmlPullParserException {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(false);
mParser = factory.newPullParser();
StringReader in = new StringReader(ttmlFragment);
mParser.setInput(in);
}
use of org.xmlpull.v1.XmlPullParserFactory in project processdash by dtuma.
the class ArchiveMetricsFileImporter method readAndProcessArchive.
private void readAndProcessArchive() throws IOException, XmlPullParserException {
shouldDeleteArchiveFileOnCompletion = false;
zipFile = new ZipFile(file);
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
XmlPullParser parser = factory.newPullParser();
InputStream manifestIn = openEntry(zipFile, MANIFEST_FILE_NAME);
parser.setInput(manifestIn, ENCODING);
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, ARCHIVE_ELEM);
if (!FILE_TYPE_ARCHIVE.equals(parser.getAttributeValue(null, TYPE_ATTR)))
error("expected archive of type " + FILE_TYPE_ARCHIVE);
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, EXPORTED_TAG);
owner = parser.getAttributeValue(null, OWNER_ATTR);
exportTimestamp = XMLUtils.parseDate(parser.getAttributeValue(null, WHEN_ATTR));
ImportedDefectManager.closeDefects(prefix);
ImportedTimeLogManager.getInstance().closeTimeLogs(prefix);
ImportedEVManager.getInstance().closeTaskLists(prefix);
defns = new HashMap();
Map<String, String> packageIDs = new HashMap<String, String>();
while (parser.next() != XmlPullParser.END_DOCUMENT) {
if (parser.getEventType() == XmlPullParser.START_TAG) {
if (PACKAGE_ELEM.equals(parser.getName())) {
String id = parser.getAttributeValue(null, PACKAGE_ID_ATTR);
String version = parser.getAttributeValue(null, VERSION_ATTR);
packageIDs.put(id, version);
} else if (FROM_DATASET_TAG.equals(parser.getName())) {
srcDatasetID = parser.getAttributeValue(null, FROM_DATASET_ID_ATTR);
} else if (FILE_ELEM.equals(parser.getName())) {
String name = parser.getAttributeValue(null, FILE_NAME_ATTR);
String type = parser.getAttributeValue(null, TYPE_ATTR);
String version = parser.getAttributeValue(null, VERSION_ATTR);
readFile(zipFile, name, type, version);
}
}
}
// make a note of the individual who exported this data
recordKnownPerson();
// Protect this data from being viewed via external http requests.
defns.put("_Password_", ImmutableDoubleData.READ_ONLY_ZERO);
// Save metadata about the import
addImportMetadata(packageIDs);
try {
data.mountImportedData(prefix, defns);
} catch (InvalidDatafileFormat idf) {
}
}
Aggregations