Example usage for twitter4j Status getInReplyToStatusId

List of usage examples for twitter4j Status getInReplyToStatusId

Introduction

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

Prototype

long getInReplyToStatusId();

Source Link

Document

Returns the in_reply_tostatus_id

Usage

From source file:com.daiv.android.twitter.data.sq_lite.MentionsDataSource.java

License:Apache License

public synchronized void createTweet(Status status, int account, boolean initial) {
    ContentValues values = new ContentValues();
    String originalName = "";
    long id = status.getId();
    long time = status.getCreatedAt().getTime();

    String[] html = TweetLinkUtils.getLinksInStatus(status);
    String text = html[0];/*from  www .ja v a 2  s.  co m*/
    String media = html[1];
    String otherUrl = html[2];
    String hashtags = html[3];
    String users = html[4];

    if (media.contains("/tweet_video/")) {
        media = media.replace("tweet_video", "tweet_video_thumb").replace(".mp4", ".png");
    }

    values.put(MentionsSQLiteHelper.COLUMN_ACCOUNT, account);
    values.put(MentionsSQLiteHelper.COLUMN_TEXT, text);
    values.put(MentionsSQLiteHelper.COLUMN_TWEET_ID, id);
    values.put(MentionsSQLiteHelper.COLUMN_NAME, status.getUser().getName());
    values.put(MentionsSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL());
    values.put(MentionsSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName());
    values.put(MentionsSQLiteHelper.COLUMN_TIME, time);
    values.put(MentionsSQLiteHelper.COLUMN_RETWEETER, originalName);
    values.put(MentionsSQLiteHelper.COLUMN_UNREAD, 0);
    values.put(MentionsSQLiteHelper.COLUMN_PIC_URL, media);
    values.put(MentionsSQLiteHelper.COLUMN_URL, otherUrl);
    values.put(MentionsSQLiteHelper.COLUMN_PIC_URL, media);
    values.put(MentionsSQLiteHelper.COLUMN_USERS, users);
    values.put(MentionsSQLiteHelper.COLUMN_HASHTAGS, hashtags);
    values.put(MentionsSQLiteHelper.COLUMN_ANIMATED_GIF, TweetLinkUtils.getGIFUrl(status, otherUrl));
    values.put(HomeSQLiteHelper.COLUMN_CONVERSATION, status.getInReplyToStatusId() == -1 ? 0 : 1);

    try {
        database.insert(MentionsSQLiteHelper.TABLE_MENTIONS, null, values);
    } catch (Exception e) {
        open();
        database.insert(MentionsSQLiteHelper.TABLE_MENTIONS, null, values);
    }
}

From source file:com.daiv.android.twitter.data.sq_lite.MentionsDataSource.java

License:Apache License

public synchronized void createTweet(Status status, int account) {
    ContentValues values = new ContentValues();
    String originalName = "";
    long id = status.getId();
    long time = status.getCreatedAt().getTime();

    String[] html = TweetLinkUtils.getLinksInStatus(status);
    String text = html[0];//from   ww  w  . j a  v a 2s. c  o  m
    String media = html[1];
    String otherUrl = html[2];
    String hashtags = html[3];
    String users = html[4];

    if (media.contains("/tweet_video/")) {
        media = media.replace("tweet_video", "tweet_video_thumb").replace(".mp4", ".png");
    }

    values.put(MentionsSQLiteHelper.COLUMN_ACCOUNT, account);
    values.put(MentionsSQLiteHelper.COLUMN_TEXT, text);
    values.put(MentionsSQLiteHelper.COLUMN_TWEET_ID, id);
    values.put(MentionsSQLiteHelper.COLUMN_NAME, status.getUser().getName());
    values.put(MentionsSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL());
    values.put(MentionsSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName());
    values.put(MentionsSQLiteHelper.COLUMN_TIME, time);
    values.put(MentionsSQLiteHelper.COLUMN_RETWEETER, originalName);
    values.put(MentionsSQLiteHelper.COLUMN_UNREAD, 1);
    values.put(MentionsSQLiteHelper.COLUMN_PIC_URL, media);
    values.put(MentionsSQLiteHelper.COLUMN_URL, otherUrl);
    values.put(MentionsSQLiteHelper.COLUMN_USERS, users);
    values.put(MentionsSQLiteHelper.COLUMN_HASHTAGS, hashtags);
    values.put(MentionsSQLiteHelper.COLUMN_ANIMATED_GIF, TweetLinkUtils.getGIFUrl(status, otherUrl));
    values.put(HomeSQLiteHelper.COLUMN_CONVERSATION, status.getInReplyToStatusId() == -1 ? 0 : 1);

    try {
        database.insert(MentionsSQLiteHelper.TABLE_MENTIONS, null, values);
    } catch (Exception e) {
        open();
        database.insert(MentionsSQLiteHelper.TABLE_MENTIONS, null, values);
    }
}

From source file:com.daiv.android.twitter.data.sq_lite.MentionsDataSource.java

License:Apache License

public synchronized int insertTweets(List<Status> statuses, int account) {

    ContentValues[] valueses = new ContentValues[statuses.size()];

    for (int i = 0; i < statuses.size(); i++) {
        Status status = statuses.get(i);

        ContentValues values = new ContentValues();
        String originalName = "";
        long id = status.getId();
        long time = status.getCreatedAt().getTime();

        String[] html = TweetLinkUtils.getLinksInStatus(status);
        String text = html[0];// www.  j  a v  a  2s  .  c  om
        String media = html[1];
        String otherUrl = html[2];
        String hashtags = html[3];
        String users = html[4];

        if (media.contains("/tweet_video/")) {
            media = media.replace("tweet_video", "tweet_video_thumb").replace(".mp4", ".png");
        }

        values.put(MentionsSQLiteHelper.COLUMN_ACCOUNT, account);
        values.put(MentionsSQLiteHelper.COLUMN_TEXT, text);
        values.put(MentionsSQLiteHelper.COLUMN_TWEET_ID, id);
        values.put(MentionsSQLiteHelper.COLUMN_NAME, status.getUser().getName());
        values.put(MentionsSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL());
        values.put(MentionsSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName());
        values.put(MentionsSQLiteHelper.COLUMN_TIME, time);
        values.put(MentionsSQLiteHelper.COLUMN_RETWEETER, originalName);
        values.put(MentionsSQLiteHelper.COLUMN_UNREAD, 1);
        values.put(MentionsSQLiteHelper.COLUMN_PIC_URL, media);
        values.put(MentionsSQLiteHelper.COLUMN_URL, otherUrl);
        values.put(MentionsSQLiteHelper.COLUMN_USERS, users);
        values.put(MentionsSQLiteHelper.COLUMN_HASHTAGS, hashtags);
        values.put(MentionsSQLiteHelper.COLUMN_ANIMATED_GIF, TweetLinkUtils.getGIFUrl(status, otherUrl));
        values.put(HomeSQLiteHelper.COLUMN_CONVERSATION, status.getInReplyToStatusId() == -1 ? 0 : 1);

        valueses[i] = values;
    }

    return insertMultiple(valueses);
}

From source file:com.dwdesign.tweetings.model.ParcelableStatus.java

License:Open Source License

public ParcelableStatus(Status status, final long account_id, final boolean is_gap,
        final boolean large_inline_image_preview) {

    this.is_gap = is_gap;
    this.account_id = account_id;
    status_id = status.getId();// w  ww  .  ja  va2 s.c  o  m
    is_retweet = status.isRetweet();
    final Status retweeted_status = is_retweet ? status.getRetweetedStatus() : null;
    final User retweet_user = retweeted_status != null ? status.getUser() : null;
    retweet_id = retweeted_status != null ? retweeted_status.getId() : -1;
    retweeted_by_id = retweet_user != null ? retweet_user.getId() : -1;
    retweeted_by_name = retweet_user != null ? retweet_user.getName() : null;
    retweeted_by_screen_name = retweet_user != null ? retweet_user.getScreenName() : null;
    if (retweeted_status != null) {
        status = retweeted_status;
    }
    final User user = status.getUser();
    user_id = user != null ? user.getId() : -1;
    name = user != null ? user.getName() : null;
    screen_name = user != null ? user.getScreenName() : null;
    profile_image_url = user != null ? user.getProfileImageURL() : null;
    profile_image_url_string = profile_image_url != null ? profile_image_url.toString() : null;
    is_protected = user != null ? user.isProtected() : false;
    is_verified = user != null ? user.isVerified() : false;
    final MediaEntity[] medias = status.getMediaEntities();

    status_timestamp = getTime(status.getCreatedAt());
    text_html = formatStatusText(status);
    final PreviewImage preview = getPreviewImage(text_html,
            large_inline_image_preview ? INLINE_IMAGE_PREVIEW_DISPLAY_OPTION_CODE_LARGE_HIGH
                    : INLINE_IMAGE_PREVIEW_DISPLAY_OPTION_CODE_SMALL);
    text_plain = status.getText();
    retweet_count = status.getRetweetCount();
    in_reply_to_screen_name = status.getInReplyToScreenName();
    in_reply_to_status_id = status.getInReplyToStatusId();
    source = status.getSource();
    location = new ParcelableLocation(status.getGeoLocation());
    location_string = location.toString();
    is_favorite = status.isFavorited();
    has_media = medias != null && medias.length > 0 || preview.has_image;
    text = text_html != null ? Html.fromHtml(text_html) : null;
    image_preview_url_string = preview.matched_url;
    image_orig_url_string = preview.orig_url;
    image_preview_url = parseURL(image_preview_url_string);
    text_unescaped = unescape(text_html);
    String play = null;
    URLEntity[] urls = status.getURLEntities();
    if (urls != null) {
        for (final URLEntity url : urls) {
            final URL tco_url = url.getURL();
            final URL expanded_url = url.getExpandedURL();
            if (tco_url != null && expanded_url != null
                    && expanded_url.toString().contains("play.google.com/store/apps")) {
                play = expanded_url.toString();
                break;
            }

        }
    }
    play_package = play;
    is_possibly_sensitive = status.isPossiblySensitive();
}

From source file:com.dwdesign.tweetings.util.Utils.java

License:Open Source License

public static ContentValues makeStatusContentValues(Status status, final long account_id) {
    if (status == null || status.getId() <= 0)
        return null;
    final ContentValues values = new ContentValues();
    values.put(Statuses.ACCOUNT_ID, account_id);
    values.put(Statuses.STATUS_ID, status.getId());
    final boolean is_retweet = status.isRetweet();
    final Status retweeted_status = is_retweet ? status.getRetweetedStatus() : null;
    if (retweeted_status != null) {
        final User retweet_user = status.getUser();
        values.put(Statuses.RETWEET_ID, retweeted_status.getId());
        values.put(Statuses.RETWEETED_BY_ID, retweet_user.getId());
        values.put(Statuses.RETWEETED_BY_NAME, retweet_user.getName());
        values.put(Statuses.RETWEETED_BY_SCREEN_NAME, retweet_user.getScreenName());
        status = retweeted_status;// w  w w .jav a 2s  .  c o m
    }
    final User user = status.getUser();
    if (user != null) {
        final long user_id = user.getId();
        final String profile_image_url = user.getProfileImageURL().toString();
        final String name = user.getName(), screen_name = user.getScreenName();
        values.put(Statuses.USER_ID, user_id);
        values.put(Statuses.NAME, name);
        values.put(Statuses.SCREEN_NAME, screen_name);
        values.put(Statuses.IS_PROTECTED, user.isProtected() ? 1 : 0);
        values.put(Statuses.IS_VERIFIED, user.isVerified() ? 1 : 0);
        values.put(Statuses.PROFILE_IMAGE_URL, profile_image_url);
    }
    if (status.getCreatedAt() != null) {
        values.put(Statuses.STATUS_TIMESTAMP, status.getCreatedAt().getTime());
    }
    values.put(Statuses.TEXT, formatStatusText(status));
    values.put(Statuses.TEXT_PLAIN, status.getText());
    values.put(Statuses.RETWEET_COUNT, status.getRetweetCount());
    values.put(Statuses.IN_REPLY_TO_SCREEN_NAME, status.getInReplyToScreenName());
    values.put(Statuses.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId());
    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, location.getLatitude() + "," + location.getLongitude());
    }
    values.put(Statuses.IS_RETWEET, is_retweet ? 1 : 0);
    values.put(Statuses.IS_FAVORITE, status.isFavorited() ? 1 : 0);
    return values;
}

From source file:com.github.jcustenborder.kafka.connect.twitter.StatusConverter.java

License:Apache License

public static void convert(Status status, Struct struct) {
    struct.put("CreatedAt", status.getCreatedAt()).put("Id", status.getId()).put("Text", status.getText())
            .put("Source", status.getSource()).put("Truncated", status.isTruncated())
            .put("InReplyToStatusId", status.getInReplyToStatusId())
            .put("InReplyToUserId", status.getInReplyToUserId())
            .put("InReplyToScreenName", status.getInReplyToScreenName()).put("Favorited", status.isFavorited())
            .put("Retweeted", status.isRetweeted()).put("FavoriteCount", status.getFavoriteCount())
            .put("Retweet", status.isRetweet()).put("RetweetCount", status.getRetweetCount())
            .put("RetweetedByMe", status.isRetweetedByMe())
            .put("CurrentUserRetweetId", status.getCurrentUserRetweetId())
            .put("PossiblySensitive", status.isPossiblySensitive()).put("Lang", status.getLang());

    Struct userStruct;//www .j ava 2  s  .  c  o m
    if (null != status.getUser()) {
        userStruct = new Struct(USER_SCHEMA);
        convert(status.getUser(), userStruct);
    } else {
        userStruct = null;
    }
    struct.put("User", userStruct);

    Struct placeStruct;
    if (null != status.getPlace()) {
        placeStruct = new Struct(PLACE_SCHEMA);
        convert(status.getPlace(), placeStruct);
    } else {
        placeStruct = null;
    }
    struct.put("Place", placeStruct);

    Struct geoLocationStruct;
    if (null != status.getGeoLocation()) {
        geoLocationStruct = new Struct(GEO_LOCATION_SCHEMA);
        convert(status.getGeoLocation(), geoLocationStruct);
    } else {
        geoLocationStruct = null;
    }
    struct.put("GeoLocation", geoLocationStruct);
    List<Long> contributers = new ArrayList<>();

    if (null != status.getContributors()) {
        for (Long l : status.getContributors()) {
            contributers.add(l);
        }
    }
    struct.put("Contributors", contributers);

    List<String> withheldInCountries = new ArrayList<>();
    if (null != status.getWithheldInCountries()) {
        for (String s : status.getWithheldInCountries()) {
            withheldInCountries.add(s);
        }
    }
    struct.put("WithheldInCountries", withheldInCountries);

    struct.put("HashtagEntities", convert(status.getHashtagEntities()));
    struct.put("UserMentionEntities", convert(status.getUserMentionEntities()));
    struct.put("MediaEntities", convert(status.getMediaEntities()));
    struct.put("SymbolEntities", convert(status.getSymbolEntities()));
    struct.put("URLEntities", convert(status.getURLEntities()));
}

From source file:com.javielinux.api.loaders.ConversationLoader.java

License:Apache License

@Override
public BaseResponse loadInBackground() {

    try {//from  ww w. ja v a 2s.  co m
        ConversationResponse response = new ConversationResponse();

        ConnectionManager.getInstance().open(getContext());
        ArrayList<Status> tweets = new ArrayList<twitter4j.Status>();
        twitter4j.Status st = ConnectionManager.getInstance().getTwitter(request.getUserId())
                .showStatus(request.getId());

        tweets.add(st);
        while (st.getInReplyToStatusId() > 0) {
            st = ConnectionManager.getInstance().getTwitter(request.getUserId())
                    .showStatus(st.getInReplyToStatusId());
            tweets.add(st);
        }
        response.setTweets(tweets);
        return response;
    } catch (TwitterException e) {
        e.printStackTrace();
        ErrorResponse error = new ErrorResponse();
        error.setError(e, e.getMessage());
        return error;
    }

}

From source file:com.javielinux.infos.InfoTweet.java

License:Apache License

public InfoTweet(Status status) {
    urls = new ArrayList<URLContent>();
    mTypeFrom = FROM_STATUS;//from  w  w w. jav a 2s  .c o m
    id = status.getId();
    urlAvatar = status.getUser().getProfileImageURL().toString();
    userId = status.getUser().getId();
    text = status.getText();
    username = status.getUser().getScreenName();
    fullname = status.getUser().getName();
    source = status.getSource();
    toUsername = status.getInReplyToScreenName();
    toUserId = status.getInReplyToUserId();
    createAt = status.getCreatedAt();
    toReplyId = status.getInReplyToStatusId();
    favorited = status.isFavorited();
    if (status.getGeoLocation() != null) {
        latitude = status.getGeoLocation().getLatitude();
        longitude = status.getGeoLocation().getLongitude();
    }
    if (status.getRetweetedStatus() != null) {
        retweet = true;
        urlAvatarRetweet = status.getRetweetedStatus().getUser().getProfileImageURL().toString();
        textRetweet = status.getRetweetedStatus().getText();
        usernameRetweet = status.getRetweetedStatus().getUser().getScreenName();
        fullnameRetweet = status.getRetweetedStatus().getUser().getName();
        sourceRetweet = status.getRetweetedStatus().getSource();
    }

    urlTweet = "http://twitter.com/#!/" + username.toLowerCase() + PREFIX_URL_TWITTER + id;

    calculateLinks();
}

From source file:com.klinker.android.twitter.activities.tweet_viewer.fragments.ConversationFragment.java

License:Apache License

public void getReplies(final ListView listView, final long tweetId, final LinearLayout progressSpinner,
        final HoloTextView none) {

    Thread getReplies = new Thread(new Runnable() {
        @Override//from  w w w  .  j av a  2s.  co  m
        public void run() {

            if (!isRunning) {
                return;
            }

            Twitter twitter = Utils.getTwitter(context, settings);
            replies = new ArrayList<twitter4j.Status>();
            try {
                status = twitter.showStatus(tweetId);

                if (status.isRetweet()) {
                    status = status.getRetweetedStatus();
                }

                twitter4j.Status replyStatus = twitter.showStatus(status.getInReplyToStatusId());

                try {
                    while (!replyStatus.getText().equals("")) {
                        if (!isRunning) {
                            return;
                        }
                        replies.add(replyStatus);
                        Log.v("reply_status", replyStatus.getText());

                        replyStatus = twitter.showStatus(replyStatus.getInReplyToStatusId());
                    }

                } catch (Exception e) {
                    // the list of replies has ended, but we dont want to go to null
                }

            } catch (TwitterException e) {
                e.printStackTrace();
            }

            if (status != null && replies.size() > 0) {
                replies.add(0, status);
            }

            ((Activity) context).runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    try {
                        if (replies.size() > 0) {

                            ArrayList<twitter4j.Status> reversed = new ArrayList<twitter4j.Status>();
                            for (int i = replies.size() - 1; i >= 0; i--) {
                                reversed.add(replies.get(i));
                            }

                            replies = reversed;

                            adapter = new TimelineArrayAdapter(context, replies);
                            listView.setAdapter(adapter);
                            listView.setVisibility(View.VISIBLE);
                            progressSpinner.setVisibility(View.GONE);

                        } else {
                        }
                    } catch (Exception e) {
                        // none and it got the null object
                    }

                    if (status != null) {
                        // everything here worked, so get the discussion on the tweet
                        getDiscussion(listView, tweetId, progressSpinner, none, status);
                    }
                }
            });
        }
    });

    getReplies.setPriority(7);
    getReplies.start();
}

From source file:com.klinker.android.twitter.activities.tweet_viewer.fragments.ConversationFragment.java

License:Apache License

public void getDiscussion(final ListView listView, final long tweetId, final LinearLayout progressBar,
        final HoloTextView none, final Status status) {

    Log.v("talon_replies", "getting discussion");

    if (replies.size() == 0) {
        replies.add(status);//from  www  .j  a  v  a2  s .c o  m
    }

    Thread getReplies = new Thread(new Runnable() {
        @Override
        public void run() {

            if (!isRunning) {
                return;
            }

            ArrayList<twitter4j.Status> all = null;
            Twitter twitter = Utils.getTwitter(context, settings);
            try {
                Log.v("talon_replies", "looking for discussion");

                long id = status.getId();
                String screenname = status.getUser().getScreenName();

                query = new Query("@" + screenname + " since_id:" + id);

                Log.v("talon_replies", "query string: " + query.getQuery());

                try {
                    query.setCount(100);
                } catch (Throwable e) {
                    // enlarge buffer error?
                    query.setCount(30);
                }

                QueryResult result = twitter.search(query);
                Log.v("talon_replies", "result: " + result.getTweets().size());

                all = new ArrayList<twitter4j.Status>();

                do {
                    Log.v("talon_replies", "do loop repetition");
                    if (!isRunning) {
                        return;
                    }
                    List<Status> tweets = result.getTweets();

                    for (twitter4j.Status tweet : tweets) {
                        if (tweet.getInReplyToStatusId() == id) {
                            all.add(tweet);
                            Log.v("talon_replies", tweet.getText());
                        }
                    }

                    if (all.size() > 0) {
                        for (int i = all.size() - 1; i >= 0; i--) {
                            Log.v("talon_replies", "inserting into arraylist:" + all.get(i).getText());
                            replies.add(all.get(i));
                        }

                        all.clear();

                        ((Activity) context).runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                progressBar.setVisibility(View.GONE);
                                try {
                                    if (replies.size() > 0) {
                                        if (adapter == null || adapter.getCount() == 0) {
                                            adapter = new TimelineArrayAdapter(context, replies);
                                            listView.setAdapter(adapter);
                                            listView.setVisibility(View.VISIBLE);
                                        } else {
                                            Log.v("talon_replies", "notifying adapter change");
                                            adapter.notifyDataSetChanged();
                                        }
                                    } else {
                                        none.setVisibility(View.VISIBLE);
                                    }
                                } catch (Exception e) {
                                    // none and it got the null object
                                    e.printStackTrace();
                                    listView.setVisibility(View.GONE);
                                    none.setVisibility(View.VISIBLE);
                                }
                            }
                        });
                    }

                    try {
                        Thread.sleep(250);
                    } catch (Exception e) {
                        // since we are changing the arraylist for the adapter in the background, we need to make sure it
                        // gets updated before continuing
                    }

                    query = result.nextQuery();

                    if (query != null)
                        result = twitter.search(query);

                } while (query != null);

            } catch (Exception e) {
                e.printStackTrace();
            } catch (OutOfMemoryError e) {
                e.printStackTrace();
            }

            if (replies.size() < 2) {
                // nothing to show, so tell them that
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        progressBar.setVisibility(View.GONE);
                        listView.setVisibility(View.GONE);
                        none.setVisibility(View.VISIBLE);
                    }
                });
            }
        }
    });

    getReplies.setPriority(8);
    getReplies.start();

}