Android Open Source - cheepcheep Get User Info Task






From Project

Back to project page cheepcheep.

License

The source code is released under:

Apache License

If you think the Android project cheepcheep 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 org.tarrio.cheepcheep.task;
//from w ww  . jav a  2  s  .c  om
import java.util.List;

import org.tarrio.cheepcheep.Constants;
import org.tarrio.cheepcheep.R;
import org.tarrio.cheepcheep.exceptions.AuthError;
import org.tarrio.cheepcheep.exceptions.CheepCheepException;
import org.tarrio.cheepcheep.exceptions.NetError;
import org.tarrio.cheepcheep.exceptions.ParseError;
import org.tarrio.cheepcheep.exceptions.UserNotFoundError;
import org.tarrio.cheepcheep.model.Preferences;
import org.tarrio.cheepcheep.model.Tweet;
import org.tarrio.cheepcheep.model.User;

import android.app.Activity;
import android.graphics.Bitmap;

public class GetUserInfoTask extends AsyncTwitterTask {

  private String username;
  private User user;
  private List<Tweet> updates;
  private Bitmap avatar;

  public GetUserInfoTask(Activity activity, Preferences prefs,
      TaskCallback callback, String username) {
    super(activity, prefs, callback);
    this.setUsername(username);
  }

  public void setUsername(String username) {
    this.username = username;
  }

  public String getUsername() {
    return username;
  }

  public void setUser(User user) {
    this.user = user;
  }

  public User getUser() {
    return user;
  }

  public void setUpdates(List<Tweet> updates) {
    this.updates = updates;
  }

  public List<Tweet> getUpdates() {
    return updates;
  }

  public void setAvatar(Bitmap avatar) {
    this.avatar = avatar;
  }

  public Bitmap getAvatar() {
    return avatar;
  }

  @Override
  protected int getProgressMessageResource() {
    return R.string.loading_user_info;
  }

  @Override
  protected void doBackground() throws NetError, ParseError, AuthError,
      UserNotFoundError {
    setUser(twitterService.getUserInfo(getUsername()));
    try {
      setUpdates(twitterService.getUserTimeline(getUsername(),
          Constants.USER_MAX_TWEETS));
    } catch (AuthError e) {
      // This exception here doesn't really mean "authentication error".
      // It means "the user has protected updates."
      user.setSecret(true);
    }
    if (!"".equals(getUser().getAvatarUrl()))
      try {
        setAvatar(twitterService.getAvatarImage(getUser()
            .getAvatarUrl()));
      } catch (CheepCheepException e) {
        // drop; we'll do without an image if we can't get it.
      }
  }

}




Java Source Code List

org.tarrio.cheepcheep.Constants.java
org.tarrio.cheepcheep.HomeTimelineActivity.java
org.tarrio.cheepcheep.OAuthActivity.java
org.tarrio.cheepcheep.SingleTweetActivity.java
org.tarrio.cheepcheep.TweetListActions.java
org.tarrio.cheepcheep.TweetListAdapter.java
org.tarrio.cheepcheep.UserInfoActivity.java
org.tarrio.cheepcheep.dialog.CheepCheepDialog.java
org.tarrio.cheepcheep.dialog.ConfirmDeleteTweetDialog.java
org.tarrio.cheepcheep.dialog.NewTweetDialog.java
org.tarrio.cheepcheep.exceptions.AuthError.java
org.tarrio.cheepcheep.exceptions.CheepCheepException.java
org.tarrio.cheepcheep.exceptions.NetError.java
org.tarrio.cheepcheep.exceptions.ParseError.java
org.tarrio.cheepcheep.exceptions.TweetNotFoundError.java
org.tarrio.cheepcheep.exceptions.UserNotFoundError.java
org.tarrio.cheepcheep.http.HttpClientFactory.java
org.tarrio.cheepcheep.http.OAuthHttpClient.java
org.tarrio.cheepcheep.model.Preferences.java
org.tarrio.cheepcheep.model.Tweet.java
org.tarrio.cheepcheep.model.User.java
org.tarrio.cheepcheep.service.PreferencesProvider.java
org.tarrio.cheepcheep.service.TwitterJSONSerializer.java
org.tarrio.cheepcheep.service.TwitterService.java
org.tarrio.cheepcheep.service.TwitterStatusSaverService.java
org.tarrio.cheepcheep.task.AsyncTwitterTask.java
org.tarrio.cheepcheep.task.CreateNewTweetTask.java
org.tarrio.cheepcheep.task.DeleteTweetTask.java
org.tarrio.cheepcheep.task.FollowUnfollowUserTask.java
org.tarrio.cheepcheep.task.GetSingleTweetTask.java
org.tarrio.cheepcheep.task.GetUserInfoTask.java
org.tarrio.cheepcheep.task.TaskCallback.java
org.tarrio.cheepcheep.task.UpdateTweetsTask.java
org.tarrio.cheepcheep.task.VerifyCredentialsTask.java