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

License:Open Source License

public TwitterDTO getProfileImageURL(AccessToken accessToken) throws BaseAppException {
    twitter.setOAuthAccessToken(accessToken);
    TwitterDTO twitterDTO = null;/* www . java 2s.  c  o  m*/
    twitterDTO = new TwitterDTO();
    User user = null;
    try {
        user = twitter.showUser(twitter.getId());
        URL url = user.getProfileImageURL();

    } catch (TwitterException e) {
        // TODO Auto-generated catch block
        processTwitterException(e);
    }
    System.out.println(user.getName() + "<< >>" + user.getProfileImageURL());

    if (user != null) {
        if (user.getProfileImageURL() != null) {
            System.out.println("TwitterImageURL=> " + user.getProfileImageURL());
            twitterDTO.setUserImg(user.getProfileImageURL().toString());
        }
        twitterDTO.setUserName(user.getName());
    }
    return twitterDTO;
}

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

License:Open Source License

public List tweets(Twitter twitter, String screenName, TwitterDTO twitterDTO) throws BaseAppException {
    List tweetList = new ArrayList();

    List<Status> statuses = null;

    Paging paging = new Paging(1, 10);

    try {/*  ww  w .  j ava  2  s  . c o  m*/
        statuses = twitter.getUserTimeline(screenName, paging);
    } catch (TwitterException e) {
        processTwitterException(e);
    }
    int i = 1;
    if (!statuses.isEmpty()) {

        for (Status status : statuses) {
            if (i <= 10) {
                User user = status.getUser();
                twitterDTO = new TwitterDTO();
                //   
                //   if(userId==status.getUser().getId()){
                if (status.getId() != 0) {
                    System.out.println(i + "TweetId=> " + status.getId());
                    twitterDTO.setTweetId(String.valueOf(status.getId()));
                }
                if (user.getProfileImageURL() != null) {
                    twitterDTO.setUserImg(user.getProfileImageURL().toString());
                }
                if (user.getScreenName() != null) {
                    twitterDTO.setUserScreeName("http://twitter.com/" + user.getScreenName());
                }
                if (user.getName() != null) {
                    twitterDTO.setUserName(user.getName());
                }
                if (status.getText() != null) {
                    twitterDTO.setTweet(status.getText());
                }
                System.out.println(status.getId() + " : " + status.getCreatedAt() + " >> " + status.getText());
                tweetList.add(twitterDTO);
                i++;
            } else {
                break;
            }

        }

    }

    return tweetList;
}

From source file:com.freshdigitable.udonroad.CombinedScreenNameTextView.java

License:Apache License

public void setNames(User user) {
    final String name = user.getName();
    final String screenName = user.getScreenName();
    if (this.name != null && this.name.equals(name) && this.screenName != null
            && this.screenName.equals(screenName)) {
        return;/*from   ww w .  j a  v a2  s. c o m*/
    }
    final String formatted = name + (TextViewCompat.getMaxLines(this) == 2 ? "\n" : " ") + "@" + screenName;
    final SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(formatted);
    spannableStringBuilder.setSpan(STYLE_BOLD, 0, name.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    setText(spannableStringBuilder);
    this.name = name;
    this.screenName = screenName;
}

From source file:com.freshdigitable.udonroad.module.realm.UserRealm.java

License:Apache License

UserRealm(final User user) {
    this.id = user.getId();
    this.profileImageURLHttps = user.getProfileImageURLHttps();
    this.miniProfileImageURLHttps = user.getMiniProfileImageURLHttps();
    this.name = user.getName();
    this.screenName = user.getScreenName();
    this.description = user.getDescription();
    this.profileBannerMobileURL = user.getProfileBannerMobileURL();
    this.statusesCount = user.getStatusesCount();
    this.followersCount = user.getFollowersCount();
    this.friendsCount = user.getFriendsCount();
    this.favoritesCount = user.getFavouritesCount();
    this.profileLinkColor = user.getProfileLinkColor();
    this.descriptionURLEntities = URLEntityRealm.createList(user.getDescriptionURLEntities());
    this.url = user.getURL();
    if (user.getURLEntity() != null) {
        this.urlEntity = new URLEntityRealm(user.getURLEntity());
    }//from  w  w w.  j  av a  2  s  .c  o  m
    this.location = user.getLocation();
    this.verified = user.isVerified();
    this.isProtected = user.isProtected();
}

From source file:com.freshdigitable.udonroad.module.realm.UserRealm.java

License:Apache License

void merge(@NonNull User u, @NonNull Realm realm) {
    if (u.getDescription() != null) { // description is nullable
        this.description = u.getDescription();
        final URLEntity[] descriptionURLEntities = u.getDescriptionURLEntities();
        if (descriptionURLEntities != null && descriptionURLEntities.length > 0) {
            this.descriptionURLEntities.clear();
            for (URLEntity url : descriptionURLEntities) {
                this.descriptionURLEntities.add(URLEntityRealm.findOrCreateFromRealm(url, realm));
            }/*www . ja  va2s.c  o m*/
        }
    }
    this.favoritesCount = u.getFavouritesCount();
    this.followersCount = u.getFollowersCount();
    this.friendsCount = u.getFriendsCount();
    this.miniProfileImageURLHttps = u.getMiniProfileImageURLHttps();
    this.name = u.getName();
    this.profileBannerMobileURL = u.getProfileBannerMobileURL();
    this.profileImageURLHttps = u.getProfileImageURLHttps();
    this.profileLinkColor = u.getProfileLinkColor();
    this.screenName = u.getScreenName();
    this.statusesCount = u.getStatusesCount();
    this.url = u.getURL();
    final URLEntity urlEntity = u.getURLEntity();
    if (urlEntity != null && isNewUrlEntity(urlEntity)) {
        this.urlEntity = URLEntityRealm.findOrCreateFromRealm(urlEntity, realm);
    }
    this.location = u.getLocation();
    this.verified = u.isVerified();
    this.isProtected = u.isProtected();
}

From source file:com.freshdigitable.udonroad.UserInfoView.java

License:Apache License

public void bindData(User user) {
    name.setText(user.getName());
    if (user.isVerified()) {
        verifiedIcon.setVisibility(VISIBLE);
    }/* www  .  j  av a 2  s  .com*/
    if (user.isProtected()) {
        protectedIcon.setVisibility(VISIBLE);
    }
    UserInfoActivity.bindUserScreenName(screenName, user);
    final CharSequence desc = SpannableStringUtil.create(user.getDescription(),
            user.getDescriptionURLEntities());
    description.setText(desc);

    final String profileLinkColor = user.getProfileLinkColor();
    if (isColorParsable(profileLinkColor)) {
        final int color = parseColor(profileLinkColor);
        banner.setBackgroundColor(color);
    }

    bindURL(user);

    if (TextUtils.isEmpty(user.getLocation())) {
        locationIcon.setVisibility(GONE);
        location.setVisibility(GONE);
    } else {
        locationIcon.setVisibility(VISIBLE);
        location.setVisibility(VISIBLE);
        location.setText(user.getLocation());
    }
}

From source file:com.freshdigitable.udonroad.util.UserUtil.java

License:Apache License

public static User create() {
    final User mock = mock(User.class);
    when(mock.getScreenName()).thenReturn("akihito104");
    when(mock.getName()).thenReturn("Akihito Matsuda");
    when(mock.getId()).thenReturn(2000L);
    when(mock.getProfileBackgroundColor()).thenReturn("ffffff");
    when(mock.getDescription()).thenReturn("user description is here.");
    when(mock.getDescriptionURLEntities()).thenReturn(new URLEntity[0]);
    when(mock.getURL()).thenReturn(null);
    when(mock.getLocation()).thenReturn(null);
    return mock;//from w  w w . j a v a 2  s.  c  om
}

From source file:com.github.daytron.twaattin.ui.tabledecorator.NameColumnGenerator.java

License:Open Source License

/**
 * @return User name of the underlying {@link User}
 *///from w  w w .ja va 2  s. c o  m
@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
    User user = getUser(source, itemId);

    return user.getName();
}

From source file:com.github.gorbin.asne.twitter.TwitterSocialNetwork.java

License:Open Source License

private SocialPerson getSocialPerson(SocialPerson socialPerson, User user) {
    socialPerson.id = Long.toString(user.getId());
    socialPerson.name = user.getName();
    socialPerson.avatarURL = user.getBiggerProfileImageURL();
    socialPerson.profileURL = user.getURL();
    return socialPerson;
}

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

License:Apache License

public static void convert(User user, Struct struct) {
    struct.put("Id", user.getId()).put("Name", user.getName()).put("ScreenName", user.getScreenName())
            .put("Location", user.getLocation()).put("Description", user.getDescription())
            .put("ContributorsEnabled", user.isContributorsEnabled())
            .put("ProfileImageURL", user.getProfileImageURL())
            .put("BiggerProfileImageURL", user.getBiggerProfileImageURL())
            .put("MiniProfileImageURL", user.getMiniProfileImageURL())
            .put("OriginalProfileImageURL", user.getOriginalProfileImageURL())
            .put("ProfileImageURLHttps", user.getProfileImageURLHttps())
            .put("BiggerProfileImageURLHttps", user.getBiggerProfileImageURLHttps())
            .put("MiniProfileImageURLHttps", user.getMiniProfileImageURLHttps())
            .put("OriginalProfileImageURLHttps", user.getOriginalProfileImageURLHttps())
            .put("DefaultProfileImage", user.isDefaultProfileImage()).put("URL", user.getURL())
            .put("Protected", user.isProtected()).put("FollowersCount", user.getFollowersCount())
            .put("ProfileBackgroundColor", user.getProfileBackgroundColor())
            .put("ProfileTextColor", user.getProfileTextColor())
            .put("ProfileLinkColor", user.getProfileLinkColor())
            .put("ProfileSidebarFillColor", user.getProfileSidebarFillColor())
            .put("ProfileSidebarBorderColor", user.getProfileSidebarBorderColor())
            .put("ProfileUseBackgroundImage", user.isProfileUseBackgroundImage())
            .put("DefaultProfile", user.isDefaultProfile())
            .put("ShowAllInlineMedia", user.isShowAllInlineMedia()).put("FriendsCount", user.getFriendsCount())
            .put("CreatedAt", user.getCreatedAt()).put("FavouritesCount", user.getFavouritesCount())
            .put("UtcOffset", user.getUtcOffset()).put("TimeZone", user.getTimeZone())
            .put("ProfileBackgroundImageURL", user.getProfileBackgroundImageURL())
            .put("ProfileBackgroundImageUrlHttps", user.getProfileBackgroundImageUrlHttps())
            .put("ProfileBannerURL", user.getProfileBannerURL())
            .put("ProfileBannerRetinaURL", user.getProfileBannerRetinaURL())
            .put("ProfileBannerIPadURL", user.getProfileBannerIPadURL())
            .put("ProfileBannerIPadRetinaURL", user.getProfileBannerIPadRetinaURL())
            .put("ProfileBannerMobileURL", user.getProfileBannerMobileURL())
            .put("ProfileBannerMobileRetinaURL", user.getProfileBannerMobileRetinaURL())
            .put("ProfileBackgroundTiled", user.isProfileBackgroundTiled()).put("Lang", user.getLang())
            .put("StatusesCount", user.getStatusesCount()).put("GeoEnabled", user.isGeoEnabled())
            .put("Verified", user.isVerified()).put("Translator", user.isTranslator())
            .put("ListedCount", user.getListedCount()).put("FollowRequestSent", user.isFollowRequestSent());

    List<String> withheldInCountries = new ArrayList<>();
    if (null != user.getWithheldInCountries()) {
        for (String s : user.getWithheldInCountries()) {
            withheldInCountries.add(s);//w  w  w.java  2  s. c o m
        }
    }
    struct.put("WithheldInCountries", withheldInCountries);

}