Example usage for twitter4j Status getUser

List of usage examples for twitter4j Status getUser

Introduction

In this page you can find the example usage for twitter4j Status getUser.

Prototype

User getUser();

Source Link

Document

Return the user associated with the status.
This can be null if the instance is from User.getStatus().

Usage

From source file:net.lacolaco.smileessence.twitter.TweetBuilder.java

License:Open Source License

public TweetBuilder setQuotation(Status status, String text) {
    return setText(String.format("%s RT @%s: %s", text, status.getUser().getScreenName(), status.getText()));
}

From source file:net.lacolaco.smileessence.twitter.UserStreamListener.java

License:Open Source License

@Override
public void onStatus(Status status) {
    StatusCache.getInstance().put(status);
    if (isIgnoredStatus(status)) {
        return;//from   w w  w .  j a v a 2s . c  o m
    }
    StatusViewModel viewModel = new StatusViewModel(status, activity.getCurrentAccount());
    addToHome(viewModel);
    if (status.isRetweet()) {
        if (viewModel.isRetweetOfMe()) {
            addToHistory(new EventViewModel(EnumEvent.RETWEETED, status.getUser(), status));
        }
    } else if (viewModel.isMention()) {
        addToMentions(viewModel);
        EventViewModel mentioned = new EventViewModel(EnumEvent.MENTIONED, status.getUser(), status);
        Notificator.publish(activity, mentioned.getFormattedString(activity));
    }
    StatusFilter.filter(activity, viewModel);
    FavoriteCache.getInstance().put(status);
}

From source file:net.lacolaco.smileessence.twitter.util.TwitterUtils.java

License:Open Source License

/**
 * Get array of screenName in own text//from  w ww . j  av  a2 s.co m
 *
 * @param status            status
 * @param excludeScreenName
 * @return
 */
public static Collection<String> getScreenNames(Status status, String excludeScreenName) {
    ArrayList<String> names = new ArrayList<>();
    names.add(status.getUser().getScreenName());
    if (status.getUserMentionEntities() != null) {
        for (UserMentionEntity entity : status.getUserMentionEntities()) {
            if (names.contains(entity.getScreenName())) {
                continue;
            }
            names.add(entity.getScreenName());
        }
    }
    if (excludeScreenName != null) {
        names.remove(excludeScreenName);
    }
    return names;
}

From source file:net.lacolaco.smileessence.twitter.util.TwitterUtils.java

License:Open Source License

/**
 * Get "@screen_name: text" format text/*from   w  ww . ja va 2s.  c o m*/
 *
 * @param status status
 * @return summary string
 */
public static String getStatusSummary(Status status) {
    return String.format("@%s: %s", status.getUser().getScreenName(), status.getText());
}

From source file:net.lacolaco.smileessence.view.dialog.StatusDetailDialogFragment.java

License:Open Source License

private boolean isDeletable(Account account, Status status) {
    boolean deletable;
    if (!status.isRetweet()) {
        deletable = status.getUser().getId() == account.userID;
    } else {//  ww w.j a v  a2  s . c  o m
        deletable = status.getRetweetedStatus().getUser().getId() == account.userID;
    }
    return deletable;
}

From source file:net.lacolaco.smileessence.view.dialog.StatusDetailDialogFragment.java

License:Open Source License

private boolean isRetweetDeletable(Account account, Status status) {
    return status.isRetweet() && status.getUser().getId() == account.userID;
}

From source file:net.lacolaco.smileessence.view.dialog.StatusDetailDialogFragment.java

License:Open Source License

private void replyToStatus(MainActivity activity, Status status) {
    Status originalStatus = TwitterUtils.getOriginalStatus(status);
    TweetBuilder builder = new TweetBuilder().addScreenName(originalStatus.getUser().getScreenName());
    String text = builder.buildText();
    PostState.newState().beginTransaction().setText(text).setInReplyToStatusID(originalStatus.getId())
            .moveCursor(text.length()).commitWithOpen(activity);
}

From source file:net.lacolaco.smileessence.viewmodel.StatusViewModel.java

License:Open Source License

public StatusViewModel(Status status, Account account) {
    if (status.isRetweet()) {
        retweetedStatus = new StatusViewModel(status.getRetweetedStatus(), account);
    }// w  w w .j a  va2 s  .co  m
    id = status.getId();
    text = TwitterUtils.replaceURLEntities(status.getText(), status.getURLEntities(), false);
    createdAt = status.getCreatedAt();
    source = status.getSource();
    mentions = status.getUserMentionEntities();
    hashtags = status.getHashtagEntities();
    media = status.getMediaEntities();
    urls = status.getURLEntities();
    symbols = status.getSymbolEntities();
    User user = status.getUser();
    UserCache.getInstance().put(user);
    userID = user.getId();
    screenName = user.getScreenName();
    name = user.getName();
    iconURL = user.getProfileImageURLHttps();
    isProtected = user.isProtected();
    setMention(isMention(account.screenName));
    setMyStatus(isMyStatus(account.userID));
    setRetweetOfMe(isRetweetOfMe(account.userID));
}

From source file:net.naijatek.myalumni.util.taglib.TwitterTag.java

License:Open Source License

/**
 * Process the end of this tag./* w w w . j  av a2s. co  m*/
 *
 * @throws JspException if a JSP exception has occurred
 * @return int
 */
@Override
public final int doEndTag() throws JspException {

    request = (HttpServletRequest) pageContext.getRequest();
    StringBuffer sb = new StringBuffer();
    AppProp ap = AppProp.getInstance();

    //MemberVO token = null;

    //if (container != null) {
    //   token = container.getToken();
    //}

    try {
        TwitterVO twitterVO = configService.getTwitterCredentials();
        List<String> list = new ArrayList<String>();

        Twitter twitter = new Twitter(twitterVO.getTwitteruser(), twitterVO.getTwitterpswd());
        List<Status> statuses = twitter.getFriendsTimeline();
        // System.out.println("Showing friends timeline.");
        for (Status status : statuses) {
            //System.out.println(status.getUser().getName() + ":" + status.getText());
            list.add("<img src=\"" + status.getUser().getProfileImageURL()
                    + "\" height=\"48\" width=\"48\" align=\"left\"><strong>" + status.getUser().getName()
                    + "</strong>:" + status.getText());
        }

        twitterVO.setMytweets(list);
        request.setAttribute(BaseConstants.TWITTER_VO, twitterVO);
    } catch (Exception e) {
        sb.append(ap.getValue("core.errorcode.00714"));//Problem encountered while retrieving class news
    }

    return EVAL_PAGE;
}

From source file:net.nokok.twitduke.core.twitter.LambdaTwitterStream.java

License:Open Source License

public void onStatusUser(Event<User> u) {
    this.twitterStream.addListener(new StatusAdapter() {

        @Override/*from  w  ww . j  a  v a 2  s .  c o m*/
        public void onStatus(Status status) {
            u.onEvent(status.getUser());
        }

    });
}