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:com.daiv.android.twitter.data.sq_lite.HomeContentProvider.java

License:Apache License

public static int insertTweets(List<Status> statuses, int currentAccount, Context context) {
    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 mId = status.getId();
        long time = status.getCreatedAt().getTime();

        if (status.isRetweet()) {
            originalName = status.getUser().getScreenName();
            status = status.getRetweetedStatus();
        }/*w  ww.  j  av a2s. co  m*/

        String[] html = TweetLinkUtils.getLinksInStatus(status);
        String text = html[0];
        String media = html[1];
        String url = html[2];
        String hashtags = html[3];
        String users = html[4];

        String source;
        if (status.isRetweet()) {
            source = android.text.Html.fromHtml(status.getRetweetedStatus().getSource()).toString();
        } else {
            source = android.text.Html.fromHtml(status.getSource()).toString();
        }

        values.put(HomeSQLiteHelper.COLUMN_ACCOUNT, currentAccount);
        values.put(HomeSQLiteHelper.COLUMN_TEXT, text);
        values.put(HomeSQLiteHelper.COLUMN_TWEET_ID, mId);
        values.put(HomeSQLiteHelper.COLUMN_NAME, status.getUser().getName());
        values.put(HomeSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL());
        values.put(HomeSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName());
        values.put(HomeSQLiteHelper.COLUMN_TIME, time);
        values.put(HomeSQLiteHelper.COLUMN_RETWEETER, originalName);
        values.put(HomeSQLiteHelper.COLUMN_UNREAD, 1);
        values.put(HomeSQLiteHelper.COLUMN_PIC_URL, media);
        values.put(HomeSQLiteHelper.COLUMN_URL, url);
        values.put(HomeSQLiteHelper.COLUMN_USERS, users);
        values.put(HomeSQLiteHelper.COLUMN_HASHTAGS, hashtags);
        values.put(HomeSQLiteHelper.COLUMN_CLIENT_SOURCE, source);

        valueses[i] = values;
    }

    return context.getContentResolver().bulkInsert(HomeContentProvider.CONTENT_URI, valueses);
}

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

License:Apache License

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

    if (status.isRetweet()) {
        originalName = status.getUser().getScreenName();
        status = status.getRetweetedStatus();
    }/*w w  w .java 2 s . co m*/

    String[] html = TweetLinkUtils.getLinksInStatus(status);
    String text = html[0];
    String media = html[1];
    String url = html[2];
    String hashtags = html[3];
    String users = html[4];

    String source;
    if (status.isRetweet()) {
        source = android.text.Html.fromHtml(status.getRetweetedStatus().getSource()).toString();
    } else {
        source = android.text.Html.fromHtml(status.getSource()).toString();
    }

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

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

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

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

License:Apache License

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

    if (status.isRetweet()) {
        originalName = status.getUser().getScreenName();
        status = status.getRetweetedStatus();
    }/*from   w ww .j  a  v a 2  s  .  c o m*/

    String[] html = TweetLinkUtils.getLinksInStatus(status);
    String text = html[0];
    String media = html[1];
    String url = html[2];
    String hashtags = html[3];
    String users = html[4];

    String source;
    if (status.isRetweet()) {
        source = android.text.Html.fromHtml(status.getRetweetedStatus().getSource()).toString();
    } else {
        source = android.text.Html.fromHtml(status.getSource()).toString();
    }

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

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

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

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

License:Apache License

public synchronized int insertTweets(List<Status> statuses, int currentAccount, long[] lastIds) {

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

    for (int i = 0; i < statuses.size(); i++) {
        Status status = statuses.get(i);
        Long id = status.getId();
        ContentValues values = new ContentValues();

        if (id > lastIds[0]) {
            String originalName = "";
            long mId = status.getId();
            long time = status.getCreatedAt().getTime();

            if (status.isRetweet()) {
                originalName = status.getUser().getScreenName();
                status = status.getRetweetedStatus();
            }//  w  w  w. j ava2 s .  c om

            String[] html = TweetLinkUtils.getLinksInStatus(status);
            String text = html[0];
            String media = html[1];
            String url = html[2];
            String hashtags = html[3];
            String users = html[4];

            String source;
            if (status.isRetweet()) {
                source = android.text.Html.fromHtml(status.getRetweetedStatus().getSource()).toString();
            } else {
                source = android.text.Html.fromHtml(status.getSource()).toString();
            }

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

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

        } else {
            values = null;
        }

        valueses[i] = values;
    }

    ArrayList<ContentValues> vals = new ArrayList<ContentValues>();

    for (ContentValues v : valueses) {
        if (v != null) {
            vals.add(v);
        }
    }

    insertMultiple(valueses);

    return vals.size();
}

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

License:Apache License

public synchronized void createMention(Context context, Status status, int account) {
    ContentValues values = new ContentValues();
    long id = status.getId();
    long time = new GregorianCalendar().getTime().getTime(); // current time
    int type = TYPE_MENTION;

    User user = status.getUser();
    String users = "@" + user.getScreenName() + " ";
    String text = status.getText();
    String title = context.getResources().getString(R.string.mentioned_by) + " <b>@" + user.getScreenName()
            + "</b>";

    values.put(InteractionsSQLiteHelper.COLUMN_ACCOUNT, account);
    values.put(InteractionsSQLiteHelper.COLUMN_TEXT, text);
    values.put(InteractionsSQLiteHelper.COLUMN_TWEET_ID, id);
    values.put(InteractionsSQLiteHelper.COLUMN_PRO_PIC, user.getOriginalProfileImageURL());
    values.put(InteractionsSQLiteHelper.COLUMN_TIME, time);
    values.put(InteractionsSQLiteHelper.COLUMN_UNREAD, 1);
    values.put(InteractionsSQLiteHelper.COLUMN_USERS, users);
    values.put(InteractionsSQLiteHelper.COLUMN_TYPE, type);
    values.put(InteractionsSQLiteHelper.COLUMN_TITLE, title);

    try {//from  w w  w.  ja va2s  . c  o  m
        database.insert(InteractionsSQLiteHelper.TABLE_INTERACTIONS, null, values);
    } catch (Exception e) {
        open();
        database.insert(InteractionsSQLiteHelper.TABLE_INTERACTIONS, null, values);
    }
}

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

License:Apache License

public synchronized void createFavoriteUserInter(Context context, Status status, int account) {
    ContentValues values = new ContentValues();
    long id = status.getId();
    long time = new GregorianCalendar().getTime().getTime(); // current time
    int type = TYPE_FAV_USER;

    User user = status.getUser();
    String users = "@" + user.getScreenName() + " ";
    String text = status.getText();
    String title = "<b>@" + user.getScreenName() + "</b> " + context.getResources().getString(R.string.tweeted);

    values.put(InteractionsSQLiteHelper.COLUMN_ACCOUNT, account);
    values.put(InteractionsSQLiteHelper.COLUMN_TEXT, text);
    values.put(InteractionsSQLiteHelper.COLUMN_TWEET_ID, id);
    values.put(InteractionsSQLiteHelper.COLUMN_PRO_PIC, user.getOriginalProfileImageURL());
    values.put(InteractionsSQLiteHelper.COLUMN_TIME, time);
    values.put(InteractionsSQLiteHelper.COLUMN_UNREAD, 1);
    values.put(InteractionsSQLiteHelper.COLUMN_USERS, users);
    values.put(InteractionsSQLiteHelper.COLUMN_TYPE, type);
    values.put(InteractionsSQLiteHelper.COLUMN_TITLE, title);

    try {/* ww w  .j ava  2  s. c  om*/
        database.insert(InteractionsSQLiteHelper.TABLE_INTERACTIONS, null, values);
    } catch (Exception e) {
        open();
        database.insert(InteractionsSQLiteHelper.TABLE_INTERACTIONS, null, values);
    }
}

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

License:Apache License

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

    if (status.isRetweet()) {
        originalName = status.getUser().getScreenName();
        status = status.getRetweetedStatus();
    }//from ww  w  . j av a  2  s.c  om

    String[] html = TweetLinkUtils.getLinksInStatus(status);
    String text = html[0];
    String media = html[1];
    String url = 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(ListSQLiteHelper.COLUMN_TEXT, text);
    values.put(ListSQLiteHelper.COLUMN_TWEET_ID, id);
    values.put(ListSQLiteHelper.COLUMN_NAME, status.getUser().getName());
    values.put(ListSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL());
    values.put(ListSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName());
    values.put(ListSQLiteHelper.COLUMN_TIME, time);
    values.put(ListSQLiteHelper.COLUMN_RETWEETER, originalName);
    values.put(ListSQLiteHelper.COLUMN_PIC_URL, media);
    values.put(ListSQLiteHelper.COLUMN_URL, url);
    values.put(ListSQLiteHelper.COLUMN_USERS, users);
    values.put(ListSQLiteHelper.COLUMN_HASHTAGS, hashtags);
    values.put(ListSQLiteHelper.COLUMN_LIST_ID, listId);
    values.put(ListSQLiteHelper.COLUMN_ANIMATED_GIF, TweetLinkUtils.getGIFUrl(status, url));

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

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

License:Apache License

public int insertTweets(List<Status> statuses, long listId) {

    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 time = status.getCreatedAt().getTime();
        long id = status.getId();

        if (status.isRetweet()) {
            originalName = status.getUser().getScreenName();
            status = status.getRetweetedStatus();
        }/* w ww  . j  a va 2 s . c  o m*/

        String[] html = TweetLinkUtils.getLinksInStatus(status);
        String text = html[0];
        String media = html[1];
        String url = 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(ListSQLiteHelper.COLUMN_TEXT, text);
        values.put(ListSQLiteHelper.COLUMN_TWEET_ID, id);
        values.put(ListSQLiteHelper.COLUMN_NAME, status.getUser().getName());
        values.put(ListSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL());
        values.put(ListSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName());
        values.put(ListSQLiteHelper.COLUMN_TIME, time);
        values.put(ListSQLiteHelper.COLUMN_RETWEETER, originalName);
        values.put(ListSQLiteHelper.COLUMN_PIC_URL, media);
        values.put(ListSQLiteHelper.COLUMN_URL, url);
        values.put(ListSQLiteHelper.COLUMN_USERS, users);
        values.put(ListSQLiteHelper.COLUMN_HASHTAGS, hashtags);
        values.put(ListSQLiteHelper.COLUMN_LIST_ID, listId);
        values.put(ListSQLiteHelper.COLUMN_ANIMATED_GIF, TweetLinkUtils.getGIFUrl(status, url));

        valueses[i] = values;
    }

    return insertMultiple(valueses);
}

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];//ww  w. j  av  a2s.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);
    }
}