Example usage for twitter4j User getLocation

List of usage examples for twitter4j User getLocation

Introduction

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

Prototype

String getLocation();

Source Link

Document

Returns the location of the user

Usage

From source file:au.net.moon.tUtils.TUser.java

License:Open Source License

/**
 * Create a user object from a twitter4j user.
 * //from   www  .j a  v  a2  s.c o  m
 * @param twitterUser
 *            a twitter4j user object
 */
public TUser(twitter4j.User twitterUser) {
    id = twitterUser.getId();
    name = twitterUser.getName();
    screenName = twitterUser.getScreenName();
    location = twitterUser.getLocation();
    description = twitterUser.getDescription();
    if (twitterUser.getProfileImageURL() != null) {
        profileImageUrl = twitterUser.getProfileImageURL().toString();
    } else {
        profileImageUrl = "";
    }
    if (twitterUser.getURL() != null) {
        url = twitterUser.getURL().toString();
    } else {
        url = "";
    }
    createdAt = twitterUser.getCreatedAt();
    isProtected = twitterUser.isProtected();
    followersCount = twitterUser.getFollowersCount();
    // Not interested in users latest tweet, so just leave blank
    status = "";
    profileBackgroundColor = twitterUser.getProfileBackgroundColor();
    profileTextColor = twitterUser.getProfileTextColor();
    profileLinkColor = twitterUser.getProfileLinkColor();
    profileSidebarFillColor = twitterUser.getProfileSidebarFillColor();
    profileSidebarBorderColor = twitterUser.getProfileSidebarBorderColor();
    friendsCount = twitterUser.getFriendsCount();
    favouritesCount = twitterUser.getFavouritesCount();
    utcOffset = twitterUser.getUtcOffset();
    timeZone = twitterUser.getTimeZone();
    if (twitterUser.getOriginalProfileImageURL() != null) {
        profileBackgroundImageUrl = twitterUser.getOriginalProfileImageURL().toString();
    } else {
        profileBackgroundImageUrl = "";
    }
    isProfileBackgroundTiled = twitterUser.isProfileBackgroundTiled();
    statusesCount = twitterUser.getStatusesCount();
    isGeoEnabled = twitterUser.isGeoEnabled();
    isVerified = twitterUser.isVerified();
    // isFollowing = twitterUser.isFollowing();

    isContributorsEnabled = twitterUser.isContributorsEnabled();
    isProfileUseBackgroundImage = twitterUser.isProfileUseBackgroundImage();
    isShowAllInLineMedia = twitterUser.isShowAllInlineMedia();
    lang = twitterUser.getLang();
    isTranslator = twitterUser.isTranslator();
    listedCount = twitterUser.getListedCount();
    isFollowRequestSent = twitterUser.isFollowRequestSent();

    // TODO: Need to pass in the searchAPI id if I have it.
    searchAPI_userID = "";
}

From source file:br.com.porcelli.hornetq.integration.twitter.support.TweetMessageConverterSupport.java

License:Apache License

private static void buildUserData(final String prefix, final User user, ServerMessage msg) {
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_ID, read(user.getId()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_NAME, read(user.getName()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_SCREEN_NAME, read(user.getScreenName()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_LOCATION, read(user.getLocation()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_DESCRIPTION, read(user.getDescription()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_PROFILE_IMAGE_URL,
            read(user.getProfileImageURL()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_URL, read(user.getURL()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_LANG, read(user.getLang()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_PROTECTED, read(user.isProtected()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_FOLLOWERS_COUNT, read(user.getFollowersCount()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_FRIENDS_COUNT, read(user.getFriendsCount()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_CREATED_AT, read(user.getCreatedAt()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_FAVOURITES_COUNT, read(user.getFavouritesCount()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_UTC_OFFSET, read(user.getUtcOffset()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_TIME_ZONE, read(user.getTimeZone()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_STATUSES_COUNT, read(user.getStatusesCount()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_VERIFIED, read(user.isVerified()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_CONTRIBUTORS_ENABLED,
            read(user.isContributorsEnabled()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_GEO_ENABLED, read(user.isGeoEnabled()));
}

From source file:com.ahuralab.mozaic.db.Message.java

License:Open Source License

public static Message create(Status status) {

    User user = status.getUser();

    return new Message(status.getText(), status.getCreatedAt(), status.getRetweetCount(), user.getId(),
            user.getName(), user.getScreenName(), user.getLocation(), user.getDescription(),
            user.getProfileImageURL(), status.getId(), 0, 0, user.getFollowersCount(), user.getStatusesCount());
}

From source file:com.daemon.database.Transactor.java

License:Open Source License

/**
 * Creates an error message with user information for further analysis.
 * @param user The user whose information is to be represented.
 * @return The error message./*from   ww w .  j  ava  2  s .  c o  m*/
 */
private String getUserErrorString(User user) {
    StringBuffer sb = new StringBuffer();

    sb.append("User information:\n");
    sb.append("  id: " + user.getId() + "\n");
    sb.append("  screen name: " + user.getScreenName() + "\n");
    sb.append("  name: " + user.getName() + "\n");
    sb.append("  description: " + user.getDescription() + "\n");
    sb.append("    length: " + user.getDescription().length() + "\n");
    sb.append("   elength: " + StringUtil.escapeNonAscii(user.getDescription()).length() + "\n");
    sb.append("  language: " + user.getLang() + "\n");
    sb.append("  location: " + user.getLocation());

    return sb.toString();
}

From source file:com.daemon.database.Transactor.java

License:Open Source License

/**
 * Adds only the given User to the SQL.Batch which will be saved
 *  in the DB by savedAllTweetsTransactionsafe  
 * /*w  w  w. jav  a2  s  . com*/
 * @param user The user to be saved.
 * @throws SQLException
 */
private void saveUser(User user) throws SQLException {
    prepStatementUser.setLong(1, user.getId());
    prepStatementUser.setString(2, user.getName());
    prepStatementUser.setString(3, user.getScreenName());
    prepStatementUser.setString(4, user.getProfileImageURL());
    prepStatementUser.setTimestamp(5, new java.sql.Timestamp(user.getCreatedAt().getTime()));
    prepStatementUser.setString(6, user.getLocation());
    prepStatementUser.setString(7, user.getURL());
    prepStatementUser.setString(8, user.getLang());
    prepStatementUser.setInt(9, user.getFollowersCount());
    prepStatementUser.setBoolean(10, user.isVerified());
    prepStatementUser.setString(11, user.getTimeZone());
    prepStatementUser.setString(12, user.getDescription());
    prepStatementUser.setInt(13, user.getStatusesCount());
    prepStatementUser.setInt(14, user.getFriendsCount());

    prepStatementUser.addBatch();
}

From source file:com.dwdesign.tweetings.fragment.UserProfileFragment.java

License:Open Source License

public void changeUser(final long account_id, final User user) {
    mFriendship = null;//  w w  w. j  ava  2  s.co  m
    mUserId = -1;
    mAccountId = -1;
    if (user == null || user.getId() <= 0 || getActivity() == null
            || !isMyActivatedAccount(getActivity(), account_id))
        return;
    if (mUserInfoTask != null && mUserInfoTask.getStatus() == AsyncTask.Status.RUNNING) {
        mUserInfoTask.cancel(true);
    }
    final boolean is_my_activated_account = isMyActivatedAccount(getActivity(), user.getId());
    mUserInfoTask = null;
    mErrorRetryContainer.setVisibility(View.GONE);
    mAccountId = account_id;
    mUserId = user.getId();
    mScreenName = user.getScreenName();

    updateUserColor();
    final boolean is_multiple_account_enabled = getActivatedAccountIds(getActivity()).length > 1;

    mListView.setBackgroundResource(is_multiple_account_enabled ? R.drawable.ic_label_account_nopadding : 0);
    if (is_multiple_account_enabled) {
        final Drawable d = mListView.getBackground();
        if (d != null) {
            d.mutate().setColorFilter(getAccountColor(getActivity(), account_id), PorterDuff.Mode.MULTIPLY);
            mListView.invalidate();
        }
    }

    mNameView.setText(user.getName());
    mScreenNameView.setText("@" + user.getScreenName());
    mScreenNameView.setCompoundDrawablesWithIntrinsicBounds(
            getUserTypeIconRes(user.isVerified(), user.isProtected()), 0, 0, 0);
    final String description = user.getDescription();
    mDescriptionContainer
            .setVisibility(is_my_activated_account || !isNullOrEmpty(description) ? View.VISIBLE : View.GONE);
    mDescriptionContainer.setOnLongClickListener(this);
    mDescriptionView.setText(description);
    final TwidereLinkify linkify = new TwidereLinkify(mDescriptionView);
    linkify.setOnLinkClickListener(this);
    linkify.addAllLinks();
    mDescriptionView.setMovementMethod(LinkMovementMethod.getInstance());
    final String location = user.getLocation();
    mLocationContainer
            .setVisibility(is_my_activated_account || !isNullOrEmpty(location) ? View.VISIBLE : View.GONE);
    mLocationContainer.setOnLongClickListener(this);
    mLocationView.setText(location);
    final String url = user.getURL() != null ? user.getURL().toString() : null;
    mURLContainer.setVisibility(is_my_activated_account || !isNullOrEmpty(url) ? View.VISIBLE : View.GONE);
    mURLContainer.setOnLongClickListener(this);
    mURLView.setText(url);
    mCreatedAtView.setText(formatToLongTimeString(getActivity(), getTimestampFromDate(user.getCreatedAt())));
    mTweetCount.setText(String.valueOf(user.getStatusesCount()));
    mFollowersCount.setText(String.valueOf(user.getFollowersCount()));
    mFriendsCount.setText(String.valueOf(user.getFriendsCount()));
    // final boolean display_profile_image =
    // mPreferences.getBoolean(PREFERENCE_KEY_DISPLAY_PROFILE_IMAGE, true);
    // mProfileImageView.setVisibility(display_profile_image ? View.VISIBLE
    // : View.GONE);
    // if (display_profile_image) {
    final String profile_image_url_string = parseString(user.getProfileImageURL());
    final boolean hires_profile_image = getResources().getBoolean(R.bool.hires_profile_image);
    mLazyImageLoader.displayProfileImage(mProfileImageView,
            hires_profile_image ? getBiggerTwitterProfileImage(profile_image_url_string)
                    : profile_image_url_string);
    // }

    String profile_banner_url_string = parseString(user.getProfileBannerImageUrl());
    if (profile_banner_url_string != null) {
        final int def_width = getResources().getDisplayMetrics().widthPixels;
        profile_banner_url_string = profile_banner_url_string + "/" + getBestBannerType(def_width);
    }
    final String banner_url = profile_banner_url_string;
    if (mProfileBackgroundView != null) {
        mProfileBackgroundView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        if (banner_url != null) {
            mLazyImageLoader.displayPreviewImage(mProfileBackgroundView, banner_url);
        } else {
            final Drawable d = getResources().getDrawable(R.drawable.linen);
            mProfileBackgroundView.setImageDrawable(d);
        }
    }

    mUser = user;
    if (isMyAccount(getActivity(), user.getId())) {
        final ContentResolver resolver = getContentResolver();
        final ContentValues values = new ContentValues();
        final URL profile_image_url = user.getProfileImageURL();
        if (profile_image_url != null) {
            values.put(Accounts.PROFILE_IMAGE_URL, profile_image_url.toString());
        }
        values.put(Accounts.USERNAME, user.getScreenName());
        final String where = Accounts.USER_ID + " = " + user.getId() + " AND 1 = 1";
        resolver.update(Accounts.CONTENT_URI, values, where, null);
    }
    mAdapter.add(new UserRecentPhotosAction());
    mAdapter.add(new FavoritesAction());
    mAdapter.add(new UserMentionsAction());
    mAdapter.add(new UserListTypesAction());
    if (user.getId() == mAccountId) {
        mAdapter.add(new MyTweetsRetweetedAction());
        mAdapter.add(new SavedSearchesAction());
        boolean nativeMapSupported = true;
        try {
            Class.forName("com.google.android.maps.MapActivity");
            Class.forName("com.google.android.maps.MapView");
        } catch (final ClassNotFoundException e) {
            nativeMapSupported = false;
        }
        if (nativeMapSupported) {
            mAdapter.add(new UserNearbyAction());
        }
        if (user.isProtected()) {
            mAdapter.add(new IncomingFriendshipsAction());
        }
        mAdapter.add(new UserBlocksAction());
    }
    mAdapter.notifyDataSetChanged();

    if (mRecentPhotosGallery != null) {
        mRecentPhotosGallery.setVisibility(View.GONE);
        mRecentPhotosGallery.setAdapter(new ImageAdapter(this.getActivity()));
        mRecentPhotosGallery.setOnItemClickListener(new OnItemClickListener() {

            public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                ParcelableStatus pStatus = mMediaStatuses.get(position);
                final ImageSpec spec = getAllAvailableImage(pStatus.image_orig_url_string);
                if (spec != null) {
                    openImage(UserProfileFragment.this.getActivity(), Uri.parse(spec.full_image_link),
                            pStatus.is_possibly_sensitive);
                }
            }

        });

        mMediaTimelineTask = new MediaTimelineTask(this.getActivity(), mAccountId, mUser.getScreenName());
        if (mMediaTimelineTask != null) {
            mMediaTimelineTask.execute();
        }
    }

    getFriendship();
    checkPushTracked();
}

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  w w  w  .  ja va2  s .c  o  m
    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.eventattend.portal.bl.TwitterBL.java

License:Open Source License

public TwitterDTO fetchProfile(User user, TwitterDTO twitterDTO) {
    System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    String userDesc = null;/*from   w w  w. j ava 2s .co  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;
}

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 a v  a  2s  .  c  om
    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));
            }//from  w  w  w.  j  a v a  2  s  . com
        }
    }
    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();
}