Example usage for twitter4j Status isRetweet

List of usage examples for twitter4j Status isRetweet

Introduction

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

Prototype

boolean isRetweet();

Source Link

Usage

From source file:org.hornetq.integration.twitter.impl.IncomingTweetsHandler.java

License:Apache License

private void putTweetIntoMessage(final Status status, final ServerMessage msg) {
    msg.getBodyBuffer().writeString(status.getText());
    msg.putLongProperty(TwitterConstants.KEY_ID, status.getId());
    msg.putStringProperty(TwitterConstants.KEY_SOURCE, status.getSource());

    msg.putLongProperty(TwitterConstants.KEY_CREATED_AT, status.getCreatedAt().getTime());
    msg.putBooleanProperty(TwitterConstants.KEY_IS_TRUNCATED, status.isTruncated());
    msg.putLongProperty(TwitterConstants.KEY_IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId());
    msg.putIntProperty(TwitterConstants.KEY_IN_REPLY_TO_USER_ID, status.getInReplyToUserId());
    msg.putBooleanProperty(TwitterConstants.KEY_IS_FAVORITED, status.isFavorited());
    msg.putBooleanProperty(TwitterConstants.KEY_IS_RETWEET, status.isRetweet());
    msg.putObjectProperty(TwitterConstants.KEY_CONTRIBUTORS, status.getContributors());
    GeoLocation gl;/*from   w  ww  .  j  a v a 2  s  .co m*/
    if ((gl = status.getGeoLocation()) != null) {
        msg.putDoubleProperty(TwitterConstants.KEY_GEO_LOCATION_LATITUDE, gl.getLatitude());
        msg.putDoubleProperty(TwitterConstants.KEY_GEO_LOCATION_LONGITUDE, gl.getLongitude());
    }
    Place place;
    if ((place = status.getPlace()) != null) {
        msg.putStringProperty(TwitterConstants.KEY_PLACE_ID, place.getId());
    }
}

From source file:org.kuali.mobility.conference.controllers.ConferenceController.java

License:Open Source License

@RequestMapping(value = "twitter-search", method = RequestMethod.GET)
public ResponseEntity<String> twitterSearch(@RequestParam(value = "term", required = true) String searchParam,
        @RequestParam(value = "since", required = false) String sinceParam, HttpServletRequest request) {

    Twitter twitter = TwitterFactory.getSingleton();
    Query query = new Query(searchParam.isEmpty() ? "#kualidays" : searchParam);
    QueryResult result = null;// ww w . j  a  va  2  s. c o  m
    query.setSince(!sinceParam.isEmpty() ? sinceParam : "2014-01-01");
    query.setCount(100);
    query.setResultType(Query.MIXED);
    String json = "";
    List<String> tweetList = new ArrayList<String>();

    try {
        result = twitter.search(query);
    } catch (TwitterException e) {
        System.err.println("Caught 'twitterSearch' IOException: " + e.getMessage());
    }

    String tweetInfo = "";
    for (Status status : result.getTweets()) {
        tweetInfo = "{";
        tweetInfo += "\"id\" : \"" + status.getId() + "\", ";
        tweetInfo += "\"avatar\" : \"" + status.getUser().getProfileImageURL() + "\", ";
        tweetInfo += "\"tweetedOn\" : \"" + status.getCreatedAt() + "\", ";
        tweetInfo += "\"tweetedOnParsed\" : \"" + status.getCreatedAt().getTime() + "\", ";
        tweetInfo += "\"screenname\" : \"" + status.getUser().getScreenName() + "\", ";
        tweetInfo += "\"status\" : \""
                + StringEscapeUtils.escapeHtml(status.getText().replaceAll("(\\r|\\n)", "")) + "\", ";
        tweetInfo += "\"truncated\" : \"" + (status.isTruncated() ? "true" : "false") + "\",";
        tweetInfo += "\"retweeted\" : \"" + (status.isRetweet() ? "true" : "false") + "\"";
        tweetInfo += "}";

        tweetList.add(tweetInfo);
    }

    json = "[" + StringUtils.arrayToDelimitedString(tweetList.toArray(), ",") + "]";

    return new ResponseEntity<String>(json, HttpStatus.OK);
}

From source file:org.mariotaku.twidere.model.ParcelableStatus.java

License:Open Source License

public ParcelableStatus(final Status orig, final long account_id, final boolean is_gap) {
    this.is_gap = is_gap;
    this.account_id = account_id;
    id = orig.getId();// w  w  w. j  a  v a  2 s. c  om
    timestamp = getTime(orig.getCreatedAt());

    final Status retweeted = orig.getRetweetedStatus();
    final User retweet_user = retweeted != null ? orig.getUser() : null;
    is_retweet = orig.isRetweet();
    retweet_id = retweeted != null ? retweeted.getId() : -1;
    retweet_timestamp = retweeted != null ? getTime(retweeted.getCreatedAt()) : -1;
    retweeted_by_user_id = retweet_user != null ? retweet_user.getId() : -1;
    retweeted_by_user_name = retweet_user != null ? retweet_user.getName() : null;
    retweeted_by_user_screen_name = retweet_user != null ? retweet_user.getScreenName() : null;
    retweeted_by_user_profile_image = retweet_user != null ? retweet_user.getProfileImageUrlHttps() : null;

    final Status quoted = orig.getQuotedStatus();
    final User quote_user = quoted != null ? orig.getUser() : null;
    is_quote = orig.isQuote();
    quote_id = quoted != null ? quoted.getId() : -1;
    quote_text_html = TwitterContentUtils.formatStatusText(orig);
    quote_text_plain = orig.getText();
    quote_text_unescaped = HtmlEscapeHelper.toPlainText(quote_text_html);
    quote_timestamp = orig.getCreatedAt().getTime();
    quote_source = orig.getSource();

    quoted_by_user_id = quote_user != null ? quote_user.getId() : -1;
    quoted_by_user_name = quote_user != null ? quote_user.getName() : null;
    quoted_by_user_screen_name = quote_user != null ? quote_user.getScreenName() : null;
    quoted_by_user_profile_image = quote_user != null ? quote_user.getProfileImageUrlHttps() : null;
    quoted_by_user_is_protected = quote_user != null && quote_user.isProtected();
    quoted_by_user_is_verified = quote_user != null && quote_user.isVerified();

    final Status status;
    if (quoted != null) {
        status = quoted;
    } else if (retweeted != null) {
        status = retweeted;
    } else {
        status = orig;
    }
    final User user = status.getUser();
    user_id = user.getId();
    user_name = user.getName();
    user_screen_name = user.getScreenName();
    user_profile_image_url = user.getProfileImageUrlHttps();
    user_is_protected = user.isProtected();
    user_is_verified = user.isVerified();
    user_is_following = user.isFollowing();
    text_html = TwitterContentUtils.formatStatusText(status);
    media = ParcelableMedia.fromStatus(status);
    quote_media = quoted != null ? ParcelableMedia.fromStatus(orig) : null;
    text_plain = status.getText();
    retweet_count = status.getRetweetCount();
    favorite_count = status.getFavoriteCount();
    reply_count = status.getReplyCount();
    descendent_reply_count = status.getDescendentReplyCount();
    in_reply_to_name = TwitterContentUtils.getInReplyToName(retweeted != null ? retweeted : orig);
    in_reply_to_screen_name = (retweeted != null ? retweeted : orig).getInReplyToScreenName();
    in_reply_to_status_id = (retweeted != null ? retweeted : orig).getInReplyToStatusId();
    in_reply_to_user_id = (retweeted != null ? retweeted : orig).getInReplyToUserId();
    source = status.getSource();
    location = ParcelableLocation.fromGeoLocation(status.getGeoLocation());
    is_favorite = status.isFavorited();
    text_unescaped = HtmlEscapeHelper.toPlainText(text_html);
    my_retweet_id = retweeted_by_user_id == account_id ? id : status.getCurrentUserRetweet();
    is_possibly_sensitive = status.isPossiblySensitive();
    mentions = ParcelableUserMention.fromUserMentionEntities(status.getUserMentionEntities());
    card = ParcelableCardEntity.fromCardEntity(status.getCard(), account_id);
    place_full_name = getPlaceFullName(status.getPlace());
    card_name = card != null ? card.name : null;
}

From source file:org.mariotaku.twidere.task.CacheUsersStatusesTask.java

License:Open Source License

@SafeVarargs
@Override//from   w ww.  j  av  a  2 s  .  co m
protected final Object doInBackground(final TwitterListResponse<twitter4j.Status>... args) {
    if (args == null || args.length == 0)
        return null;
    final ContentResolver resolver = context.getContentResolver();
    final Extractor extractor = new Extractor();

    for (final TwitterListResponse<twitter4j.Status> response : args) {
        if (response == null || response.list == null) {
            continue;
        }
        final List<twitter4j.Status> list = response.list;
        for (int bulkIdx = 0, totalSize = list.size(); bulkIdx < totalSize; bulkIdx += 100) {
            for (int idx = bulkIdx, end = Math.min(totalSize,
                    bulkIdx + ContentResolverUtils.MAX_BULK_COUNT); idx < end; idx++) {
                final twitter4j.Status status = list.get(idx);

                final Set<ContentValues> usersValues = new HashSet<>();
                final Set<ContentValues> statusesValues = new HashSet<>();
                final Set<ContentValues> hashTagValues = new HashSet<>();

                statusesValues.add(createStatus(status, response.accountId));
                for (final String hashtag : extractor.extractHashtags(status.getText())) {
                    final ContentValues values = new ContentValues();
                    values.put(CachedHashtags.NAME, hashtag);
                    hashTagValues.add(values);
                }
                usersValues.add(createCachedUser(status.getUser()));
                if (status.isRetweet()) {
                    usersValues.add(createCachedUser(status.getRetweetedStatus().getUser()));
                }

                bulkInsert(resolver, CachedStatuses.CONTENT_URI, statusesValues);
                bulkInsert(resolver, CachedHashtags.CONTENT_URI, hashTagValues);
                bulkInsert(resolver, CachedUsers.CONTENT_URI, usersValues);
            }
        }
    }

    return null;
}

From source file:org.mariotaku.twidere.util.ContentValuesCreator.java

License:Open Source License

@NonNull
public static ContentValues createStatus(final Status orig, final long accountId) {
    if (orig == null)
        throw new NullPointerException();
    final ContentValues values = new ContentValues();
    values.put(Statuses.ACCOUNT_ID, accountId);
    values.put(Statuses.STATUS_ID, orig.getId());
    values.put(Statuses.STATUS_TIMESTAMP, orig.getCreatedAt().getTime());
    final Status status;
    if (orig.isRetweet()) {
        final Status retweetedStatus = orig.getRetweetedStatus();
        final User retweetUser = orig.getUser();
        final long retweetedById = retweetUser.getId();
        values.put(Statuses.RETWEET_ID, retweetedStatus.getId());
        values.put(Statuses.RETWEET_TIMESTAMP, retweetedStatus.getCreatedAt().getTime());
        values.put(Statuses.RETWEETED_BY_USER_ID, retweetedById);
        values.put(Statuses.RETWEETED_BY_USER_NAME, retweetUser.getName());
        values.put(Statuses.RETWEETED_BY_USER_SCREEN_NAME, retweetUser.getScreenName());
        values.put(Statuses.RETWEETED_BY_USER_PROFILE_IMAGE, (retweetUser.getProfileImageUrlHttps()));
        values.put(Statuses.IS_RETWEET, true);
        if (retweetedById == accountId) {
            values.put(Statuses.MY_RETWEET_ID, orig.getId());
        } else {/*from  w w w .  jav  a 2s.co  m*/
            values.put(Statuses.MY_RETWEET_ID, orig.getCurrentUserRetweet());
        }
        status = retweetedStatus;
    } else if (orig.isQuote()) {
        final Status quotedStatus = orig.getQuotedStatus();
        final User quoteUser = orig.getUser();
        final long quotedById = quoteUser.getId();
        values.put(Statuses.QUOTE_ID, quotedStatus.getId());
        final String textHtml = TwitterContentUtils.formatStatusText(orig);
        values.put(Statuses.QUOTE_TEXT_HTML, textHtml);
        values.put(Statuses.QUOTE_TEXT_PLAIN, orig.getText());
        values.put(Statuses.QUOTE_TEXT_UNESCAPED, toPlainText(textHtml));
        values.put(Statuses.QUOTE_TIMESTAMP, orig.getCreatedAt().getTime());
        values.put(Statuses.QUOTE_SOURCE, orig.getSource());
        final ParcelableMedia[] quoteMedia = ParcelableMedia.fromStatus(orig);
        if (quoteMedia != null && quoteMedia.length > 0) {
            try {
                values.put(Statuses.QUOTE_MEDIA_JSON,
                        LoganSquare.serialize(Arrays.asList(quoteMedia), ParcelableMedia.class));
            } catch (IOException ignored) {
            }
        }
        values.put(Statuses.QUOTED_BY_USER_ID, quotedById);
        values.put(Statuses.QUOTED_BY_USER_NAME, quoteUser.getName());
        values.put(Statuses.QUOTED_BY_USER_SCREEN_NAME, quoteUser.getScreenName());
        values.put(Statuses.QUOTED_BY_USER_PROFILE_IMAGE, quoteUser.getProfileImageUrlHttps());
        values.put(Statuses.QUOTED_BY_USER_IS_VERIFIED, quoteUser.isVerified());
        values.put(Statuses.QUOTED_BY_USER_IS_PROTECTED, quoteUser.isProtected());
        values.put(Statuses.IS_QUOTE, true);
        status = quotedStatus;
    } else {
        values.put(Statuses.MY_RETWEET_ID, orig.getCurrentUserRetweet());
        status = orig;
    }
    if (orig.isRetweet()) {
        values.put(Statuses.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId());
        values.put(Statuses.IN_REPLY_TO_USER_ID, status.getInReplyToUserId());
        values.put(Statuses.IN_REPLY_TO_USER_NAME, TwitterContentUtils.getInReplyToName(status));
        values.put(Statuses.IN_REPLY_TO_USER_SCREEN_NAME, status.getInReplyToScreenName());
    } else {
        values.put(Statuses.IN_REPLY_TO_STATUS_ID, orig.getInReplyToStatusId());
        values.put(Statuses.IN_REPLY_TO_USER_ID, orig.getInReplyToUserId());
        values.put(Statuses.IN_REPLY_TO_USER_NAME, TwitterContentUtils.getInReplyToName(orig));
        values.put(Statuses.IN_REPLY_TO_USER_SCREEN_NAME, orig.getInReplyToScreenName());
    }
    final User user = status.getUser();
    final long userId = user.getId();
    final String profileImageUrl = (user.getProfileImageUrlHttps());
    final String name = user.getName(), screenName = user.getScreenName();
    values.put(Statuses.USER_ID, userId);
    values.put(Statuses.USER_NAME, name);
    values.put(Statuses.USER_SCREEN_NAME, screenName);
    values.put(Statuses.IS_PROTECTED, user.isProtected());
    values.put(Statuses.IS_VERIFIED, user.isVerified());
    values.put(Statuses.USER_PROFILE_IMAGE_URL, profileImageUrl);
    values.put(CachedUsers.IS_FOLLOWING, user.isFollowing());
    final String textHtml = TwitterContentUtils.formatStatusText(status);
    values.put(Statuses.TEXT_HTML, textHtml);
    values.put(Statuses.TEXT_PLAIN, status.getText());
    values.put(Statuses.TEXT_UNESCAPED, toPlainText(textHtml));
    values.put(Statuses.RETWEET_COUNT, status.getRetweetCount());
    values.put(Statuses.REPLY_COUNT, status.getReplyCount());
    values.put(Statuses.FAVORITE_COUNT, status.getFavoriteCount());
    values.put(Statuses.DESCENDENT_REPLY_COUNT, status.getDescendentReplyCount());
    values.put(Statuses.SOURCE, status.getSource());
    values.put(Statuses.IS_POSSIBLY_SENSITIVE, status.isPossiblySensitive());
    final GeoLocation location = status.getGeoLocation();
    if (location != null) {
        values.put(Statuses.LOCATION,
                ParcelableLocation.toString(location.getLatitude(), location.getLongitude()));
    }
    final Place place = status.getPlace();
    if (place != null) {
        values.put(Statuses.PLACE_FULL_NAME, place.getFullName());
    }
    values.put(Statuses.IS_FAVORITE, status.isFavorited());
    final ParcelableMedia[] media = ParcelableMedia.fromStatus(status);
    if (media != null && media.length > 0) {
        try {
            values.put(Statuses.MEDIA_JSON, LoganSquare.serialize(Arrays.asList(media), ParcelableMedia.class));
        } catch (IOException ignored) {
        }
    }
    final ParcelableUserMention[] mentions = ParcelableUserMention.fromStatus(status);
    if (mentions != null && mentions.length > 0) {
        try {
            values.put(Statuses.MENTIONS_JSON,
                    LoganSquare.serialize(Arrays.asList(mentions), ParcelableUserMention.class));
        } catch (IOException ignored) {
        }
    }
    final ParcelableCardEntity card = ParcelableCardEntity.fromCardEntity(status.getCard(), accountId);
    if (card != null) {
        try {
            values.put(Statuses.CARD, LoganSquare.serialize(card));
            values.put(Statuses.CARD_NAME, card.name);
        } catch (IOException ignored) {
        }
    }
    return values;
}

From source file:org.seasr.meandre.apps.twitter.TwitterToTuple.java

public void onStatus(Status status) {
    String text = status.getText();

    //// ww w.  j  a v  a2  s  .co m
    // cull out as much as possible here
    //
    text = TwitterServices.convertToASCII(text);
    if (text == null) {
        // console.info("SKIP non-ascii " + status.getText());
        return;
    }

    float pct = TwitterServices.parsingPercentage(text);
    if (pct < 0.40) {
        // console.info("SKIP " + pct + " " + text);
        return;
    }

    User user = status.getUser();
    String location = TwitterServices.getLocation(status);

    /*
    if (location == TwitterServices.NO_LOCATION) {
       return;
    }
    */

    //console.info("Raw      " + status.getText());
    if (status.isRetweet()) {
        console.fine("YES RT " + status.getText());
    }

    String clean = clean(text);

    /*
    if (c.length() != text.length()) {
       console.info(text);
       console.info(c);
    }
    */

    outTuple.setValue(ID_IDX, ID++);
    outTuple.setValue(USER_IDX, user.getId());
    outTuple.setValue(FOLLOWERS_IDX, user.getFavouritesCount());
    outTuple.setValue(TWEET_IDX, text);
    outTuple.setValue(TEXT_IDX, clean);
    outTuple.setValue(LOCATION_IDX, location);

    // console.info("got data ");

    synchronized (buffer) {

        buffer.add(outTuple.convert());

        if (buffer.size() > WINDOW_SIZE) {

            // console.info("wake the waiter " + buffer.size());
            buffer.notifyAll();

        }

    }
    // console.info("leaving");

}

From source file:org.smarttechie.servlet.SimpleStream.java

public void getStream(TwitterStream twitterStream, String[] parametros, final Session session)//,PrintStream out)
{

    listener = new StatusListener() {

        @Override//w w w .  j a  v a2 s. c  om
        public void onException(Exception arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onScrubGeo(long arg0, long arg1) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onStatus(Status status) {
            Twitter twitter = new TwitterFactory().getInstance();
            User user = status.getUser();

            // gets Username
            String username = status.getUser().getScreenName();
            System.out.println("");
            String profileLocation = user.getLocation();
            System.out.println(profileLocation);
            long tweetId = status.getId();
            System.out.println(tweetId);
            String content = status.getText();
            System.out.println(content + "\n");

            JSONObject obj = new JSONObject();
            obj.put("User", status.getUser().getScreenName());
            obj.put("ProfileLocation", user.getLocation().replaceAll("'", "''"));
            obj.put("Id", status.getId());
            obj.put("UserId", status.getUser().getId());
            //obj.put("User", status.getUser());
            obj.put("Message", status.getText().replaceAll("'", "''"));
            obj.put("CreatedAt", status.getCreatedAt().toString());
            obj.put("CurrentUserRetweetId", status.getCurrentUserRetweetId());
            //Get user retweeteed
            String otheruser;
            try {
                if (status.getCurrentUserRetweetId() != -1) {
                    User user2 = twitter.showUser(status.getCurrentUserRetweetId());
                    otheruser = user2.getScreenName();
                    System.out.println("Other user: " + otheruser);
                }
            } catch (Exception ex) {
                System.out.println("ERROR: " + ex.getMessage().toString());
            }
            obj.put("IsRetweet", status.isRetweet());
            obj.put("IsRetweeted", status.isRetweeted());
            obj.put("IsFavorited", status.isFavorited());

            obj.put("InReplyToUserId", status.getInReplyToUserId());
            //In reply to
            obj.put("InReplyToScreenName", status.getInReplyToScreenName());

            obj.put("RetweetCount", status.getRetweetCount());
            if (status.getGeoLocation() != null) {
                obj.put("GeoLocationLatitude", status.getGeoLocation().getLatitude());
                obj.put("GeoLocationLongitude", status.getGeoLocation().getLongitude());
            }

            JSONArray listHashtags = new JSONArray();
            String hashtags = "";
            for (HashtagEntity entity : status.getHashtagEntities()) {
                listHashtags.add(entity.getText());
                hashtags += entity.getText() + ",";
            }

            if (!hashtags.isEmpty())
                obj.put("HashtagEntities", hashtags.substring(0, hashtags.length() - 1));

            if (status.getPlace() != null) {
                obj.put("PlaceCountry", status.getPlace().getCountry());
                obj.put("PlaceFullName", status.getPlace().getFullName());
            }

            obj.put("Source", status.getSource());
            obj.put("IsPossiblySensitive", status.isPossiblySensitive());
            obj.put("IsTruncated", status.isTruncated());

            if (status.getScopes() != null) {
                JSONArray listScopes = new JSONArray();
                String scopes = "";
                for (String scope : status.getScopes().getPlaceIds()) {
                    listScopes.add(scope);
                    scopes += scope + ",";
                }

                if (!scopes.isEmpty())
                    obj.put("Scopes", scopes.substring(0, scopes.length() - 1));
            }

            obj.put("QuotedStatusId", status.getQuotedStatusId());

            JSONArray list = new JSONArray();
            String contributors = "";
            for (long id : status.getContributors()) {
                list.add(id);
                contributors += id + ",";
            }

            if (!contributors.isEmpty())
                obj.put("Contributors", contributors.substring(0, contributors.length() - 1));

            System.out.println("" + obj.toJSONString());

            insertNodeNeo4j(obj);

            //out.println(obj.toJSONString());
            String statement = "INSERT INTO TweetsClassification JSON '" + obj.toJSONString() + "';";
            executeQuery(session, statement);
        }

        @Override
        public void onTrackLimitationNotice(int arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onStallWarning(StallWarning sw) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

    };
    FilterQuery fq = new FilterQuery();

    fq.track(parametros);

    twitterStream.addListener(listener);
    twitterStream.filter(fq);
}

From source file:org.tweetalib.android.model.TwitterMediaEntity.java

License:Apache License

public static TwitterMediaEntity createMediaEntity(Status status) {
    MediaEntity[] mediaEntities;// w w w .  ja v a 2 s  . c  o m
    URLEntity[] urlEntities;

    if (status.isRetweet()) {
        mediaEntities = status.getRetweetedStatus().getMediaEntities();
        urlEntities = status.getRetweetedStatus().getURLEntities();
    } else {
        mediaEntities = status.getMediaEntities();
        urlEntities = status.getURLEntities();
    }

    if (mediaEntities != null && mediaEntities.length > 0) {
        return new TwitterMediaEntity(mediaEntities[0]);
    } else if (urlEntities != null) {
        for (URLEntity urlEntity : urlEntities) {
            // This shouldn't be necessary, but is
            String expandedUrl = urlEntity.getExpandedURL();
            if (expandedUrl == null) {
                continue;
            }

            TwitterMediaEntity entity = getTwitterMediaEntityFromUrl(urlEntity.getURL(),
                    urlEntity.getExpandedURL());
            if (entity != null) {
                return entity;
            }
        }
    }

    return null;
}

From source file:org.tweetalib.android.model.TwitterStatus.java

License:Apache License

public TwitterStatus(Status status) {
    User statusUser = status.getUser();/* www . j a va  2s.c om*/

    mCreatedAt = status.getCreatedAt();
    mId = status.getId();
    if (status.getInReplyToStatusId() != -1) {
        mInReplyToStatusId = status.getInReplyToStatusId();
    }
    if (status.getInReplyToUserId() != -1) {
        mInReplyToUserId = status.getInReplyToUserId();
    }
    mInReplyToUserScreenName = status.getInReplyToScreenName();
    mIsFavorited = status.isFavorited();
    mIsRetweet = status.isRetweet();
    mIsRetweetedByMe = status.isRetweetedByMe();

    mSource = TwitterUtil.stripMarkup(status.getSource());

    if (statusUser != null) {
        mUserId = statusUser.getId();
        mUserName = statusUser.getName();
        mUserScreenName = statusUser.getScreenName();
    }

    mMediaEntity = TwitterMediaEntity.createMediaEntity(status);

    boolean useDefaultAuthor = true;
    if (mIsRetweet) {
        if (status.getRetweetedStatus() != null && status.getRetweetedStatus().getUser() != null) {
            SetProfileImagesFromUser(new TwitterUser(status.getRetweetedStatus().getUser()));
        }
        mOriginalRetweetId = status.getRetweetedStatus().getId();

        // You'd think this check wasn't necessary, but apparently not...
        UserMentionEntity[] userMentions = status.getUserMentionEntities();
        if (userMentions != null && userMentions.length > 0) {
            useDefaultAuthor = false;
            UserMentionEntity authorMentionEntity = status.getUserMentionEntities()[0];
            mAuthorId = authorMentionEntity.getId();
            mAuthorName = authorMentionEntity.getName();
            mAuthorScreenName = authorMentionEntity.getScreenName();

            Status retweetedStatus = status.getRetweetedStatus();
            mStatus = retweetedStatus.getText();
            setStatusMarkup(retweetedStatus);
            mRetweetCount = retweetedStatus.getRetweetCount();
            mUserMentions = TwitterUtil.getUserMentions(retweetedStatus.getUserMentionEntities());
            mIsRetweetedByMe = retweetedStatus.isRetweetedByMe();
        }
    } else {
        if (statusUser != null) {
            SetProfileImagesFromUser(new TwitterUser(statusUser));
        }
    }

    if (useDefaultAuthor) {
        if (statusUser != null) {
            mAuthorId = statusUser.getId();
        }
        mStatus = status.getText();
        setStatusMarkup(status);
        mRetweetCount = status.getRetweetCount();
        mUserMentions = TwitterUtil.getUserMentions(status.getUserMentionEntities());
    }

    /*
     * if (status.getId() == 171546910249852928L) { mStatus =
     * "<a href=\"http://a.com\">@chrismlacy</a> You've been working on Tweet Lanes for ages. Is it done yet?"
     * ; mStatusMarkup =
     * "<a href=\"http://a.com\">@chrismlacy</a> You've been working on Tweet Lanes for ages. Is it done yet?"
     * ; mAuthorScreenName = "emmarclarke"; mStatusMarkup = mStatus; } else
     * if (status.getId() == 171444098698457089L) { mStatus =
     * "<a href=\"http://a.com\">@chrismlacy</a> How's that app of yours coming along?"
     * ; mStatusMarkup =
     * "<a href=\"http://a.com\">@chrismlacy</a> How's that app of yours coming along?"
     * ; mStatusMarkup = mStatus; }
     */
}

From source file:org.tweetalib.android.model.TwitterStatuses.java

License:Apache License

public void add(ResponseList<twitter4j.Status> statuses, AddUserCallback addUserCallback) {

    TwitterStatus firstItem = size() > 0 ? get(0) : null;
    int addCount = 0;

    boolean stillMore = true;
    TwitterStatus lastAddedStatus = null;

    mGetNewStatusesMaxId = null;/*from   ww w  .j  av a 2 s . c om*/

    for (Status status : statuses) {
        if (firstItem != null && status.getId() == firstItem.mId) {
            stillMore = false;
            break;
        }

        lastAddedStatus = new TwitterStatus(status);
        add(lastAddedStatus);

        if (addUserCallback != null) {
            addUserCallback.addUser(status.getUser());
            if (status.isRetweet()) {
                Status retweetedStatus = status.getRetweetedStatus();
                if (retweetedStatus != null) {
                    addUserCallback.addUser(retweetedStatus.getUser());
                }
            }
        }

        addCount += 1;
    }

    if (stillMore && lastAddedStatus != null) {
        mGetNewStatusesMaxId = lastAddedStatus.mId;
    }

    if (addCount > 0) {
        sort();
    }
}