Android Open Source - TumblifeForAndroid T L User Parser






From Project

Back to project page TumblifeForAndroid.

License

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.

Java Source Code

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;
  }
}




Java Source Code List

jp.mitukiii.tumblife.App.java
jp.mitukiii.tumblife.HardkeySetting.java
jp.mitukiii.tumblife.KeyCodeMap.java
jp.mitukiii.tumblife.Main.java
jp.mitukiii.tumblife.Setting.java
jp.mitukiii.tumblife.exeption.TLAuthenticationFailureException.java
jp.mitukiii.tumblife.exeption.TLFailureException.java
jp.mitukiii.tumblife.exeption.TLParserException.java
jp.mitukiii.tumblife.exeption.TLSDCardNotFoundException.java
jp.mitukiii.tumblife.model.TLModel.java
jp.mitukiii.tumblife.model.TLPost.java
jp.mitukiii.tumblife.model.TLSetting.java
jp.mitukiii.tumblife.model.TLTumblelog.java
jp.mitukiii.tumblife.model.TLUser.java
jp.mitukiii.tumblife.parser.TLParser.java
jp.mitukiii.tumblife.parser.TLPostParser.java
jp.mitukiii.tumblife.parser.TLUserParser.java
jp.mitukiii.tumblife.tumblr.TLDashboardDelegate.java
jp.mitukiii.tumblife.tumblr.TLDashboardInterface.java
jp.mitukiii.tumblife.tumblr.TLDashboard.java
jp.mitukiii.tumblife.ui.TLWebViewClientDelegate.java
jp.mitukiii.tumblife.ui.TLWebViewClient.java
jp.mitukiii.tumblife.util.TLBrowser.java
jp.mitukiii.tumblife.util.TLConnection.java
jp.mitukiii.tumblife.util.TLExplorer.java
jp.mitukiii.tumblife.util.TLLog.java
jp.mitukiii.tumblife.util.TLPostFactory.java