Example usage for twitter4j User getName

List of usage examples for twitter4j User getName

Introduction

In this page you can find the example usage for twitter4j User getName.

Prototype

String getName();

Source Link

Document

Returns the name of the user

Usage

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

License:Open Source License

public ParcelableDirectMessage(final DirectMessage message, final long account_id, final boolean is_gap) {
    this.account_id = account_id;
    this.is_gap = is_gap;
    final User sender = message.getSender(), recipient = message.getRecipient();
    message_id = message.getId();//from   w w w  .  j a  v  a 2s  .  co m
    message_timestamp = getTime(message.getCreatedAt());
    sender_id = sender != null ? sender.getId() : -1;
    recipient_id = recipient != null ? recipient.getId() : -1;
    text = message.getText();
    sender_name = sender != null ? sender.getName() : null;
    recipient_name = recipient != null ? recipient.getName() : null;
    sender_screen_name = sender != null ? sender.getScreenName() : null;
    recipient_screen_name = recipient != null ? recipient.getScreenName() : null;
    sender_profile_image_url = sender != null ? sender.getProfileImageURL() : null;
    recipient_profile_image_url = recipient != null ? recipient.getProfileImageURL() : null;
}

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();/*from  w  w w  .j a  v  a 2 s .  c om*/
    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.model.ParcelableUser.java

License:Open Source License

public ParcelableUser(final User user, final long account_id, final long position) {
    this.position = position;
    this.account_id = account_id;
    user_id = user.getId();/*from ww w. j a v  a 2s .c om*/
    created_at = getTime(user.getCreatedAt());
    is_protected = user.isProtected();
    is_verified = user.isVerified();
    name = user.getName();
    screen_name = user.getScreenName();
    description = user.getDescription();
    location = user.getLocation();
    profile_image_url = user.getProfileImageURL();
    profile_image_url_string = parseString(profile_image_url);
}

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

License:Open Source License

public ParcelableUserList(final UserList list, final long account_id, final long position) {
    final User user = list.getUser();
    this.position = position;
    this.account_id = account_id;
    list_id = list.getId();//  ww  w  .jav a  2 s . c o  m
    is_public = list.isPublic();
    is_following = list.isFollowing();
    name = list.getName();
    description = list.getDescription();
    user_id = user.getId();
    user_name = user.getName();
    user_screen_name = user.getScreenName();
    user_profile_image_url = user.getProfileImageURL();
    user_profile_image_url_string = parseString(user_profile_image_url);
}

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

License:Open Source License

public static ContentValues makeCachedUserContentValues(final User user) {
    if (user == null || user.getId() <= 0)
        return null;
    final ContentValues values = new ContentValues();
    values.put(CachedUsers.NAME, user.getName());
    values.put(CachedUsers.PROFILE_IMAGE_URL, user.getProfileImageURL().toString());
    values.put(CachedUsers.SCREEN_NAME, user.getScreenName());
    values.put(CachedUsers.USER_ID, user.getId());
    return values;
}

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

License:Open Source License

public static ContentValues makeDirectMessageContentValues(final DirectMessage message, final long account_id) {
    if (message == null || message.getId() <= 0)
        return null;
    final ContentValues values = new ContentValues();
    final User sender = message.getSender(), recipient = message.getRecipient();
    if (sender == null || recipient == null)
        return null;
    values.put(DirectMessages.ACCOUNT_ID, account_id);
    values.put(DirectMessages.MESSAGE_ID, message.getId());
    values.put(DirectMessages.MESSAGE_TIMESTAMP, message.getCreatedAt().getTime());
    values.put(DirectMessages.SENDER_ID, sender.getId());
    values.put(DirectMessages.RECIPIENT_ID, recipient.getId());
    values.put(DirectMessages.TEXT, message.getText());
    values.put(DirectMessages.SENDER_NAME, sender.getName());
    values.put(DirectMessages.SENDER_SCREEN_NAME, sender.getScreenName());
    values.put(DirectMessages.RECIPIENT_NAME, recipient.getName());
    values.put(DirectMessages.RECIPIENT_SCREEN_NAME, recipient.getScreenName());
    final URL sender_profile_image_url = sender.getProfileImageURL();
    final URL recipient_profile_image_url = recipient.getProfileImageURL();
    if (sender_profile_image_url != null) {
        values.put(DirectMessages.SENDER_PROFILE_IMAGE_URL, sender_profile_image_url.toString());
    }/* www .j  a v  a  2  s . c  om*/
    if (recipient_profile_image_url != null) {
        values.put(DirectMessages.RECIPIENT_PROFILE_IMAGE_URL, recipient_profile_image_url.toString());
    }
    return values;
}

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  2  s  .  co  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.eventattend.portal.bl.TwitterBL.java

License:Open Source License

public boolean testTwitter(AccessToken accessToken) throws BaseAppException {
    boolean result = false;
    User user = null;
    try {/*w w w  . j a  v a2  s .  c  om*/
        twitter.setOAuthAccessToken(accessToken);
        user = twitter.verifyCredentials();
        System.out.println("Welcome " + user.getName() + " to Twitter! You are successfully connected.");
        result = true;

    } catch (TwitterException e) {
        processTwitterException(e);
        System.out.println("Unable to connect to Twitter..!");
    }

    return result;

}

From source file:com.eventattend.portal.bl.TwitterBL.java

License:Open Source License

public List searchTweets(String msg, AccessToken accessToken, String userTimeZone, TwitterDTO twitterDTO)
        throws BaseAppException {

    twitter.setOAuthAccessToken(accessToken);
    List twitterSearchList = null;
    DateUtility dateUtility = new DateUtility();
    twitterSearchList = new ArrayList();
    // TwitterDTO twitterDTO = null;      
    String tweetContect = null;//from   w  w  w .ja  va2s .c om
    String lang = null;
    Query query = null;
    QueryResult result = null;
    try {
        //query.setSince("2010-10-09"); 
        if (twitterDTO.getEventTags() != null) {
            String[] eventTags = twitterDTO.getEventTags();
            for (int i = 0; i < eventTags.length; i++) {
                query = new Query(eventTags[i]);
                result = twitter.search(query);
                int tweetBreak = 0;
                if (APP_MODE.equalsIgnoreCase("DEVELOPMENT")) {
                    tweetBreak = 1;
                } else {
                    tweetBreak = 5;
                }

                int initTweetCount = 0;
                for (Tweet tweet : result.getTweets()) {

                    twitterDTO = new TwitterDTO();
                    User user = null;
                    lang = tweet.getIsoLanguageCode();

                    /*To include RichContent to the Tweet Created Time*/
                    Date dt = tweet.getCreatedAt();
                    /*To convert the Tweeted date user Time Zone*/
                    TimeZone userTimeZ = TimeZone.getTimeZone(userTimeZone);
                    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    df.setTimeZone(userTimeZ);
                    String today = df.format(dt);
                    String createdTime = today;
                    String tweetCreatedAt = dateUtility.sessionCommentTimeCheck(createdTime, userTimeZone);
                    //System.out.println(initTweetCount +" "+tweet.getIsoLanguageCode()+" "+tweet.getCreatedAt()+" "+tweet.getFromUserId()+" <<>> "+tweet.getFromUser()+" <<>> "+tweet.getText()+" << >> "+tweet.getProfileImageUrl());
                    if (lang.equals("en")) {
                        initTweetCount++;
                        System.out.println(
                                initTweetCount + " " + tweet.getIsoLanguageCode() + " " + tweet.getCreatedAt()
                                        + " " + tweet.getFromUserId() + " <<>> " + tweet.getFromUser()
                                        + " <<>> " + tweet.getText() + " << >> " + tweet.getProfileImageUrl());

                        try {
                            if (tweet.getFromUser() != null) {
                                user = twitter.showUser(tweet.getFromUser());
                            }

                        } catch (TwitterException e) {
                            processTwitterException(e);
                        }

                        if (user != null) {
                            if (tweet.getFromUser() != null) {
                                twitterDTO.setTweetCreatedAt(tweetCreatedAt);
                                twitterDTO.setUserImg(tweet.getProfileImageUrl());
                                twitterDTO.setUserScreeName("http://twitter.com/" + tweet.getFromUser());
                                twitterDTO.setUserName(user.getName());
                                tweetContect = tweet.getText();

                                /*To include RichContent to the Tweet*/
                                StringBuffer tweetText = new StringBuffer(tweetContect);
                                String delimiters = " ";
                                String rep = null;
                                String repText = tweetText.toString();
                                repText = changeTweetToRichContent(repText);
                                //System.out.println("repText  "+repText);
                                twitterDTO.setTweet(repText);

                            }
                        }
                        twitterSearchList.add(twitterDTO);
                    }

                    if (tweetBreak == initTweetCount) {
                        break;
                    }
                }
            }
        } else {
            query = new Query(msg);
            result = twitter.search(query);
            int tweetBreak = 0;
            if (APP_MODE.equalsIgnoreCase("DEVELOPMENT")) {
                tweetBreak = 1;
            } else {
                tweetBreak = 5;
            }
            int initTweetCount = 0;
            for (Tweet tweet : result.getTweets()) {

                twitterDTO = new TwitterDTO();
                User user = null;
                lang = tweet.getIsoLanguageCode();

                /*To include RichContent to the Tweet Created Time*/
                Date dt = tweet.getCreatedAt();
                /*To convert the Tweeted date user Time Zone*/
                TimeZone userTimeZ = TimeZone.getTimeZone(userTimeZone);
                DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                df.setTimeZone(userTimeZ);
                String today = df.format(dt);
                String createdTime = today;
                String tweetCreatedAt = dateUtility.sessionCommentTimeCheck(createdTime, userTimeZone);

                if (lang.equals("en")) {
                    initTweetCount++;
                    System.out.println(
                            initTweetCount + " " + tweet.getIsoLanguageCode() + " " + tweet.getCreatedAt() + " "
                                    + tweet.getFromUserId() + " <<>> " + tweet.getFromUser() + " <<>> "
                                    + tweet.getText() + " << >> " + tweet.getProfileImageUrl());

                    try {
                        if (tweet.getFromUser() != null) {
                            user = twitter.showUser(tweet.getFromUser());
                        }

                    } catch (TwitterException e) {
                        processTwitterException(e);
                    }

                    if (user != null) {
                        if (tweet.getFromUser() != null) {
                            twitterDTO.setTweetCreatedAt(tweetCreatedAt);
                            twitterDTO.setUserImg(tweet.getProfileImageUrl());
                            twitterDTO.setUserScreeName("http://twitter.com/" + tweet.getFromUser());
                            twitterDTO.setUserName(user.getName());
                            tweetContect = tweet.getText();

                            /*To include RichContent to the Tweet*/
                            StringBuffer tweetText = new StringBuffer(tweetContect);
                            String delimiters = " ";
                            String rep = null;
                            String repText = tweetText.toString();
                            repText = changeTweetToRichContent(repText);
                            //System.out.println("repText  "+repText);
                            twitterDTO.setTweet(repText);

                        }
                    }
                    twitterSearchList.add(twitterDTO);
                }

                if (tweetBreak == initTweetCount) {
                    break;
                }
            }
        }
    } catch (TwitterException e) {

        processTwitterException(e);

    }
    return twitterSearchList;
}

From source file:com.eventattend.portal.bl.TwitterBL.java

License:Open Source License

public TwitterDTO fetchProfile(User user, TwitterDTO twitterDTO) {
    System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    String userDesc = null;// ww  w.ja  v a  2 s.c o  m
    String favCount = null;
    String followCount = null;
    String friendsCount = null;
    String location = null;
    String name = null;
    String profImgUrl = null;
    String personalUrl = null;
    String twitterURL = "http://twitter.com/" + user.getScreenName();
    userDesc = user.getDescription();
    favCount = String.valueOf(user.getFavouritesCount());
    followCount = String.valueOf(user.getFollowersCount());
    friendsCount = String.valueOf(user.getFriendsCount());
    location = user.getLocation();
    name = user.getName();
    profImgUrl = String.valueOf(user.getProfileImageURL());
    //   System.out.println("User ID   >>  "+user.getId());
    //System.out.println("TwitterA/C CreatedAt  >>  "+user.getCreatedAt());
    System.out.println("Description   >>  " + user.getDescription());
    System.out.println("FavouritesCount   >>  " + user.getFavouritesCount());
    System.out.println("FollowersCoun   >>  " + user.getFollowersCount());
    System.out.println("FriendsCount   >>  " + user.getFriendsCount());
    System.out.println("Language   >>  " + user.getLang());
    System.out.println("Location >>  " + user.getLocation());
    System.out.println("Name  >>  " + user.getName());
    System.out.println("ProfileImageURL   >>  " + user.getProfileImageURL());
    System.out.println("Total tweets   >>  " + user.getStatusesCount());

    if (twitterURL != null) {
        twitterDTO.setUserURL(twitterURL);
        System.out.println("Twitter URL   >>  " + twitterURL);
    }
    if (userDesc != null && (!userDesc.equals(""))) {
        twitterDTO.setUserDesc(userDesc);
    } else {
        twitterDTO.setUserDesc(null);
    }
    if (favCount != null) {
        twitterDTO.setUserFavCount(favCount);
    }
    if (followCount != null) {
        twitterDTO.setFollowersCount(followCount);
    }
    if (friendsCount != null) {

        twitterDTO.setFriendsCount(friendsCount);
    }
    if (location != null) {
        twitterDTO.setUserLocation(location);
    }
    if (name != null) {
        twitterDTO.setUserName(name);
    }
    if (profImgUrl != null) {
        twitterDTO.setUserImg(profImgUrl);
    }
    if (user.getURL() != null) {
        if (!user.getURL().equals(twitterURL)) {
            personalUrl = String.valueOf(user.getURL());
            System.out.println("Personal URL   >>  " + user.getURL());
            twitterDTO.setPersonalUrl(personalUrl);
        }
    }
    //   Status status=user.getStatus();
    //   System.out.println("Latest Tweet  >> TweetId "+status.getId()+"|Tweet> "+status.getText()+" |via> "+status.getSource()
    //         +"|Loc >"+status.getGeoLocation()+"|tweetTime >"+status.getCreatedAt()+"Place Details we can get >"+status.getPlace());         
    /*System.out.println("RateLimitStatus   >>  "+user.getRateLimitStatus());
    System.out.println("ProfileBackgroundColor   >>  "+user.getProfileBackgroundColor());
    System.out.println("ProfileBackgroundImageUrl   >>  "+user.getProfileBackgroundImageUrl());
    System.out.println("ProfileLinkColor   >>  "+user.getProfileLinkColor());
    System.out.println("ProfileSidebarBorderColor   >>  "+user.getProfileSidebarBorderColor());
    System.out.println("user.getProfileSidebarFillColor()   >>  "+user.getProfileSidebarFillColor());
    System.out.println("ProfileTextColor   >>  "+user.getProfileTextColor());*/
    return twitterDTO;
}