Android Open Source - AndroidTwitterApp Tweet






From Project

Back to project page AndroidTwitterApp.

License

The source code is released under:

MIT License

If you think the Android project AndroidTwitterApp 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 net.julienlecomte.apps.basictwitter.models;
/* ww w  .ja  va 2s  .  c  om*/
import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.text.Html;

public class Tweet {
  private long uid;
  private String body;
  private String createdAt;
  private User user;

  public static Tweet fromJson(JSONObject jsonObject) {
    Tweet tweet = new Tweet();

    try {
      tweet.uid = jsonObject.getLong("id");
      tweet.body = Html.fromHtml(jsonObject.getString("text")).toString();
      tweet.createdAt = jsonObject.getString("created_at");
      tweet.user = User.fromJson(jsonObject.getJSONObject("user"));
    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    }

    return tweet;
  }

  public static ArrayList<Tweet> fromJsonArray(JSONArray jsonArray) {
    ArrayList<Tweet> tweets = new ArrayList<Tweet>();

    for (int i = 0; i < jsonArray.length(); i++) {
      JSONObject jsonObject;

      try {
        jsonObject = jsonArray.getJSONObject(i);
      } catch (JSONException e) {
        e.printStackTrace();
        continue;
      }

      Tweet tweet = Tweet.fromJson(jsonObject);
      if (tweet != null) {
        tweets.add(tweet);
      }
    }

    return tweets;
  }

  public long getUid() {
    return uid;
  }

  public String getBody() {
    return body;
  }

  public String getCreatedAt() {
    return createdAt;
  }

  public User getUser() {
    return user;
  }
}




Java Source Code List

net.julienlecomte.apps.basictwitter.ComposeActivity.java
net.julienlecomte.apps.basictwitter.EndlessScrollListener.java
net.julienlecomte.apps.basictwitter.LoginActivity.java
net.julienlecomte.apps.basictwitter.ProfileActivity.java
net.julienlecomte.apps.basictwitter.TimelineActivity.java
net.julienlecomte.apps.basictwitter.TweetArrayAdapter.java
net.julienlecomte.apps.basictwitter.TwitterApp.java
net.julienlecomte.apps.basictwitter.TwitterClient.java
net.julienlecomte.apps.basictwitter.fragments.HomeTimelineFragment.java
net.julienlecomte.apps.basictwitter.fragments.MentionsTimelineFragment.java
net.julienlecomte.apps.basictwitter.fragments.TweetsListFragment.java
net.julienlecomte.apps.basictwitter.fragments.UserTimelineFragment.java
net.julienlecomte.apps.basictwitter.listeners.FragmentTabListener.java
net.julienlecomte.apps.basictwitter.models.Tweet.java
net.julienlecomte.apps.basictwitter.models.User.java