Android Open Source - TButler Item






From Project

Back to project page TButler.

License

The source code is released under:

Tbutler includes software from Twitter4J to parse Twitter response from the Twitter API. You can see the license term at http://twitter4j.org/en/index.html#license Copyright (c) 2009-2010, David Parr...

If you think the Android project TButler 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 com.davidparry.twitter.common;
/*ww w  .j  a  v  a 2s .  c o  m*/
import java.text.SimpleDateFormat;

import android.graphics.drawable.Drawable;
import android.util.Log;

public class Item {
  Drawable image;
  String message;
  String imageSrc;
  String userId;
  long id;
  String createdAt;
  String source;
  private static final String TAG = "Item";

  
  public String toFileString() {
    StringBuffer buffer = new StringBuffer();
    buffer.append("<html><body><h3>Tweet</h3>");
    buffer.append("<img src='");
    buffer.append(this.imageSrc);
    buffer.append("'>");
    buffer.append("<br><br>");
    buffer.append("<b>status:</b>");
    buffer.append(encode(this.message));
    buffer.append("<br>");
    buffer.append("<b>userId:</b>");
    buffer.append(userId);
    buffer.append("<br>");    
    buffer.append("<b>id:</b>");
    buffer.append(this.id);
    buffer.append("<br>");
    buffer.append("<b>create date:</b>");
    buffer.append(createdAt);
    buffer.append("</body></html>");
    return buffer.toString();
  }
  
  
  
  public static String encode(String value){
    String a ="<a href='";
    String es = "</a>";
    Log.d(TAG, value);
    try {
      if(value != null){
        int v = value.indexOf("http");
        Log.d(TAG, "Index "+v);
        if(v >0){
          int t = value.indexOf(" ",v);
          String url ="";
          if(t >0){
            url = value.substring(v,t);
          } else{
            url = value.substring(v);
          }
          Log.d(TAG, "Url "+url);
          String r = a+url+"'>"+url+es;
          Log.d(TAG, "R "+r);
          value = value.replaceFirst(url,r);
        }
      }
    } catch (Exception e) {
      Log.e(TAG, "Error finding url ",e);
    }
    return value;
  }
  
  public long getId() {
    return id;
  }
  public void setId(long id) {
    this.id = id;
  }
  public String getUserId() {
    return userId;
  }
  public void setUserId(String userId) {
    this.userId = userId;
  }
  public String getImageSrc() {
    return imageSrc;
  }
  public void setImageSrc(String imageSrc) {
    this.imageSrc = imageSrc;
  }
  public Item() {}
  
  public Item(String imageSrc, String message, String userId,long id, String createdAt,String fromUser,String source) {
    this.imageSrc = imageSrc;
    this.message = message;
    this.userId = userId;
    this.id = id;
    this.createdAt = createdAt;
    this.source = source;
  }
  public Item(Tweet tweet){
    this.imageSrc = tweet.getProfileImageUrl();
    this.message = tweet.getText();
    this.userId = tweet.getFromUser();
    this.id = tweet.getId();
    String date = "";
    if(tweet.getCreatedAt() != null){
      SimpleDateFormat format = new SimpleDateFormat();
      date = format.format(tweet.getCreatedAt());
    }
    
  }
  
  
  public String getFileName() {
    return this.userId+this.id;
  }
  public Drawable getImage() {
    return image;
  }
  public void setImage(Drawable image) {
    this.image = image;
  }
  public String getMessage() {
    return message;
  }
  public void setMessage(String message) {
    this.message = message;
  }
  
  
  
}




Java Source Code List

com.davidparry.twitter.AlarmReceiver.java
com.davidparry.twitter.ButlerActivity.java
com.davidparry.twitter.ButlerException.java
com.davidparry.twitter.ButlerTabActivity.java
com.davidparry.twitter.FileListActivity.java
com.davidparry.twitter.InfoActivity.java
com.davidparry.twitter.ItemViewActivity.java
com.davidparry.twitter.OAUTH.java
com.davidparry.twitter.ProfileActivity.java
com.davidparry.twitter.ServiceActivity.java
com.davidparry.twitter.TweetList.java
com.davidparry.twitter.TweetPreferenceActivity.java
com.davidparry.twitter.TwitterPersistence.java
com.davidparry.twitter.YoutubeActivity.java
com.davidparry.twitter.analytics.ButlerAnalytics.java
com.davidparry.twitter.common.ActivityHelper.java
com.davidparry.twitter.common.Item.java
com.davidparry.twitter.common.Location.java
com.davidparry.twitter.common.ServicePreferences.java
com.davidparry.twitter.common.Tweet.java
com.davidparry.twitter.common.TwitterResult.java
com.davidparry.twitter.common.TwitterUser.java
com.davidparry.twitter.common.Util.java
com.davidparry.twitter.exception.QueryValidationException.java
com.davidparry.twitter.http.TwitterQueryRequest.java
com.davidparry.twitter.http.TwitterRequest.java
com.davidparry.twitter.listeners.ProfileImageLongClickListener.java
com.davidparry.twitter.listeners.buttons.ActionButtonDialogOnClickListener.java
com.davidparry.twitter.listeners.buttons.AdvancedSearchOnClickListener.java
com.davidparry.twitter.listeners.buttons.AuthorizeException.java
com.davidparry.twitter.listeners.buttons.BasicSearchOnClickListener.java
com.davidparry.twitter.listeners.buttons.ButtonPreference.java
com.davidparry.twitter.listeners.buttons.ListTweetsOnClickListener.java
com.davidparry.twitter.listeners.buttons.NextPageOnClickListener.java
com.davidparry.twitter.listeners.buttons.TweetActionButtonListener.java
com.davidparry.twitter.oath.TButlerOATH.java
com.davidparry.twitter.threads.ImageIconLoaderThread.java
com.davidparry.twitter.threads.ProfileUserThread.java
com.davidparry.twitter.threads.SDCardIOReadThread.java
com.davidparry.twitter.threads.SDCardIOWriteThread.java
com.davidparry.twitter.threads.StatusLongClickListener.java
com.davidparry.twitter.twitter4j.ButlerTwitterAdapter.java
com.davidparry.twitter.twitter4j.TwitterQuery.java
com.davidparry.twitter.widgets.ButlerDialog.java
com.davidparry.twitter.widgets.OptionMenu.java
com.davidparry.twitter.widgets.TwitterCheckBox.java