use of org.xmlpull.v1.XmlPullParserFactory in project LitePal by LitePalFramework.
the class ModelListActivity method populateMappingClasses.
private void populateMappingClasses() {
try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
XmlPullParser xmlPullParser = factory.newPullParser();
xmlPullParser.setInput(getInputStream(), "UTF-8");
int eventType = xmlPullParser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
String nodeName = xmlPullParser.getName();
switch(eventType) {
case XmlPullParser.START_TAG:
{
if ("mapping".equals(nodeName)) {
String className = xmlPullParser.getAttributeValue("", "class");
mList.add(className);
}
break;
}
default:
break;
}
eventType = xmlPullParser.next();
}
} catch (XmlPullParserException e) {
throw new ParseConfigurationFileException(ParseConfigurationFileException.FILE_FORMAT_IS_NOT_CORRECT);
} catch (IOException e) {
throw new ParseConfigurationFileException(ParseConfigurationFileException.IO_EXCEPTION);
}
}
use of org.xmlpull.v1.XmlPullParserFactory in project android_frameworks_base by DirtyUnicorns.
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 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;
}
Aggregations