use of org.xmlpull.v1.XmlPullParser in project HoloEverywhere by Prototik.
the class DrawableCompat method createFromXml.
public static Drawable createFromXml(Resources r, XmlPullParser parser) throws XmlPullParserException, IOException {
AttributeSet attrs = Xml.asAttributeSet(parser);
int type;
while ((type = parser.next()) != XmlPullParser.START_TAG && type != XmlPullParser.END_DOCUMENT) {
}
if (type != XmlPullParser.START_TAG) {
throw new XmlPullParserException("No start tag found");
}
Drawable drawable = createFromXmlInner(r, parser, attrs);
if (drawable == null) {
throw new RuntimeException("Unknown initial tag: " + parser.getName());
}
return drawable;
}
use of org.xmlpull.v1.XmlPullParser in project HoloEverywhere by Prototik.
the class LayerDrawable method inflate.
@Override
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException {
super.inflate(r, parser, attrs);
int type;
TypedArray a = r.obtainAttributes(attrs, R.styleable.LayerDrawable);
mOpacityOverride = a.getInt(R.styleable.LayerDrawable_android_opacity, PixelFormat.UNKNOWN);
a.recycle();
final int innerDepth = parser.getDepth() + 1;
int depth;
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && ((depth = parser.getDepth()) >= innerDepth || type != XmlPullParser.END_TAG)) {
if (type != XmlPullParser.START_TAG) {
continue;
}
if (depth > innerDepth || !parser.getName().equals("item")) {
continue;
}
a = r.obtainAttributes(attrs, R.styleable.LayerDrawableItem);
int left = a.getDimensionPixelOffset(R.styleable.LayerDrawableItem_android_left, 0);
int top = a.getDimensionPixelOffset(R.styleable.LayerDrawableItem_android_top, 0);
int right = a.getDimensionPixelOffset(R.styleable.LayerDrawableItem_android_right, 0);
int bottom = a.getDimensionPixelOffset(R.styleable.LayerDrawableItem_android_bottom, 0);
int drawableRes = a.getResourceId(R.styleable.LayerDrawableItem_android_drawable, 0);
int id = a.getResourceId(R.styleable.LayerDrawableItem_android_id, View.NO_ID);
a.recycle();
Drawable dr;
if (drawableRes != 0) {
dr = DrawableCompat.getDrawable(r, drawableRes);
} else {
while ((type = parser.next()) == XmlPullParser.TEXT) {
}
if (type != XmlPullParser.START_TAG) {
throw new XmlPullParserException(parser.getPositionDescription() + ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable");
}
dr = DrawableCompat.createFromXmlInner(r, parser, attrs);
}
addLayer(dr, id, left, top, right, bottom);
}
ensurePadding();
onStateChange(getState());
}
use of org.xmlpull.v1.XmlPullParser in project HoloEverywhere by Prototik.
the class XmlUtils method readListXml.
public static final ArrayList readListXml(InputStream in) throws XmlPullParserException, java.io.IOException {
XmlPullParser parser = Xml.newPullParser();
parser.setInput(in, null);
return (ArrayList) XmlUtils.readValueXml(parser, new String[1]);
}
use of org.xmlpull.v1.XmlPullParser in project HoloEverywhere by Prototik.
the class XmlUtils method readThisListXml.
public static final ArrayList readThisListXml(XmlPullParser parser, String endTag, String[] name) throws XmlPullParserException, java.io.IOException {
ArrayList list = new ArrayList();
int eventType = parser.getEventType();
do {
if (eventType == XmlPullParser.START_TAG) {
Object val = XmlUtils.readThisValueXml(parser, name);
list.add(val);
// System.out.println("Adding to list: " + val);
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals(endTag)) {
return list;
}
throw new XmlPullParserException("Expected " + endTag + " end tag at: " + parser.getName());
}
eventType = parser.next();
} while (eventType != XmlPullParser.END_DOCUMENT);
throw new XmlPullParserException("Document ended before " + endTag + " end tag");
}
use of org.xmlpull.v1.XmlPullParser in project HoloEverywhere by Prototik.
the class XmlUtils method readThisSetXml.
public static final HashSet readThisSetXml(XmlPullParser parser, String endTag, String[] name) throws XmlPullParserException, java.io.IOException {
HashSet set = new HashSet();
int eventType = parser.getEventType();
do {
if (eventType == XmlPullParser.START_TAG) {
Object val = XmlUtils.readThisValueXml(parser, name);
set.add(val);
// System.out.println("Adding to set: " + val);
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals(endTag)) {
return set;
}
throw new XmlPullParserException("Expected " + endTag + " end tag at: " + parser.getName());
}
eventType = parser.next();
} while (eventType != XmlPullParser.END_DOCUMENT);
throw new XmlPullParserException("Document ended before " + endTag + " end tag");
}
Aggregations