Back to project page TumblifeForAndroid.
The source code is released under:
GNU General Public License
If you think the Android project TumblifeForAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package jp.mitukiii.tumblife.parser; // w w w. ja v a 2 s .co m import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import jp.mitukiii.tumblife.model.TLTumblelog; import jp.mitukiii.tumblife.model.TLUser; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; public class TLUserParser extends TLParser { public TLUserParser(InputStream input) throws XmlPullParserException { super(input); } public TLUser parse() throws XmlPullParserException, IOException { TLUser user = new TLUser(); List<TLTumblelog> tumblelogs = new ArrayList<TLTumblelog>(); for (int e = parser.getEventType(); e != XmlPullParser.END_DOCUMENT; e = parser.next()) { if (e == XmlPullParser.START_TAG) { String tag = parser.getName(); if ("tumblelog".equals(tag)) { TLTumblelog tumblelog = new TLTumblelog(); tumblelog.setTitle(parser.getAttributeValue(NAME_SPACE, "title")); tumblelog.setAdmin("1".equals(parser.getAttributeValue(NAME_SPACE, "is-admin"))); tumblelog.setTwitterEnabled("1".equals(parser.getAttributeValue(NAME_SPACE, "twitter-enabled"))); tumblelog.setType(parser.getAttributeValue(NAME_SPACE, "type")); if ("private".equals(tumblelog.getType())) { tumblelog.setPrimary(false); } else if ("public".equals(tumblelog.getType())) { tumblelog.setName(parser.getAttributeValue(NAME_SPACE, "name")); tumblelog.setUrl(parser.getAttributeValue(NAME_SPACE, "url")); tumblelog.setAvatarUrl(parser.getAttributeValue(NAME_SPACE, "avatar-url")); tumblelog.setPrimary("yes".equals(parser.getAttributeValue(NAME_SPACE, "is-primary"))); } tumblelogs.add(tumblelog); } } } user.setTumblelogs(tumblelogs); return user; } }