Example usage for twitter4j User getCreatedAt

List of usage examples for twitter4j User getCreatedAt

Introduction

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

Prototype

Date getCreatedAt();

Source Link

Usage

From source file:MainActivity.java

public void setTwitter(Twitter t) throws TwitterException, MalformedURLException, IOException {

    twitter = t;//from   ww w.j  av a 2s  .c om
    screenName = twitter.getScreenName();
    name.setText(twitter.getScreenName());

    twitter4j.User user = twitter.showUser(twitter.getId());
    URL url = new URL(user.getBiggerProfileImageURL());
    //URL url = new URL(fullUrlPath);
    BufferedImage img = ImageIO.read(url);
    ImageIcon icon = new ImageIcon(img);
    imgIcon.setIcon(icon);
    //JOptionPane.showMessageDialog(null, icon);
    Afollowing.setText(user.getFriendsCount() + "");
    Afollowers.setText(user.getFollowersCount() + "");
    createdAt.setText(user.getCreatedAt() + "");
    lists.setText(user.getListedCount() + "");
    favourites.setText(user.getFavouritesCount() + "");
    tweets.setText(user.getStatusesCount() + "");

}

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

License:Open Source License

/**
 * Create a user object from a twitter4j user.
 * /*w w  w .j av  a  2 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.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  
 * /*from   w  w  w . java 2 s  .c  om*/
 * @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.c  om
    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();//w  w w  . j  av a 2s  . 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.github.gorbin.asne.twitter.TwitterSocialNetwork.java

License:Open Source License

private TwitterPerson getDetailedSocialPerson(TwitterPerson twitterPerson, User user) {
    getSocialPerson(twitterPerson, user);
    twitterPerson.createdDate = user.getCreatedAt().getTime();
    twitterPerson.description = user.getDescription();
    twitterPerson.favoritesCount = user.getFavouritesCount();
    twitterPerson.followersCount = user.getFollowersCount();
    twitterPerson.friendsCount = user.getFriendsCount();
    twitterPerson.lang = user.getLang();
    twitterPerson.location = user.getLocation();
    twitterPerson.screenName = user.getScreenName();
    if (user.getStatus() != null) {
        twitterPerson.status = user.getStatus().getText();
    } else {/*w ww. j ava2s  .c  om*/
        twitterPerson.status = null;
    }
    twitterPerson.timezone = user.getTimeZone();
    twitterPerson.isTranslator = user.isTranslator();
    twitterPerson.isVerified = user.isVerified();
    return twitterPerson;
}

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);//from   w  w w .j  a va 2  s.  c om
        }
    }
    struct.put("WithheldInCountries", withheldInCountries);

}

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

License:Apache License

public InfoUsers(User user) {
    setId(user.getId());//from w w w.j a v  a 2 s .  c om
    setName(user.getScreenName());
    setFullname(user.getName());
    setCreated(user.getCreatedAt());
    setLocation(user.getLocation());
    if (user.getURL() != null)
        setUrl(user.getURL().toString());
    setFollowers(user.getFollowersCount());
    setFollowing(user.getFriendsCount());
    setTweets(user.getStatusesCount());
    setBio(user.getDescription());
    if (user.getStatus() != null)
        setTextTweet(user.getStatus().getText());
    setUrlAvatar(user.getProfileImageURL().toString());

    ArrayList<Entity> ents = DataFramework.getInstance().getEntityList("users",
            "service is null or service = \"twitter.com\"");

    for (Entity ent : ents) {
        friendly.put(ent.getString("name"), new Friend(ent.getString("name")));
    }

}

From source file:com.marpies.ane.twitter.utils.UserUtils.java

License:Apache License

public static JSONObject getJSON(User user) throws JSONException {
    JSONObject userJSON = new JSONObject();
    userJSON.put("id", user.getId());
    userJSON.put("screenName", user.getScreenName());
    userJSON.put("name", user.getName());
    userJSON.put("createdAt", user.getCreatedAt());
    userJSON.put("description", user.getDescription());
    userJSON.put("tweetsCount", user.getStatusesCount());
    userJSON.put("likesCount", user.getFavouritesCount());
    userJSON.put("followersCount", user.getFollowersCount());
    userJSON.put("friendsCount", user.getFriendsCount());
    userJSON.put("profileImageURL", user.getProfileImageURL());
    userJSON.put("isProtected", user.isProtected());
    userJSON.put("isVerified", user.isVerified());
    userJSON.put("location", user.getLocation());
    return userJSON;
}