Example usage for twitter4j Relationship getTargetUserId

List of usage examples for twitter4j Relationship getTargetUserId

Introduction

In this page you can find the example usage for twitter4j Relationship getTargetUserId.

Prototype

long getTargetUserId();

Source Link

Document

Returns the target user id

Usage

From source file:info.maslowis.twitterripper.command.impl.twitter.FriendUpdateId.java

License:Open Source License

@Override
public void execute() throws ExecuteCmdException {
    try {//from  ww w.j a  v  a  2s .c om
        Relationship relationship = twitter.updateFriendship(id, device, retweets);
        out.println(String.format("Changed the notification settings from User{id=%1s, screenName='%2s'}",
                relationship.getTargetUserId(), relationship.getTargetUserScreenName()));
    } catch (TwitterException e) {
        throw new ExecuteCmdException(e);
    }
}

From source file:info.maslowis.twitterripper.command.impl.twitter.FriendUpdateName.java

License:Open Source License

@Override
public void execute() throws ExecuteCmdException {
    try {/*from w w w  .ja  va  2 s  .co  m*/
        Relationship relationship = twitter.updateFriendship(name, device, retweets);
        out.println(String.format("Changed the notification settings from User{id=%1s, screenName='%2s'}",
                relationship.getTargetUserId(), relationship.getTargetUserScreenName()));
    } catch (TwitterException e) {
        throw new ExecuteCmdException(e);
    }
}

From source file:org.getlantern.firetweet.fragment.support.UserFragment.java

License:Open Source License

public void displayUser(final ParcelableUser user) {
    mUser = user;//from   w w  w .j  a v  a2 s.com
    final FragmentActivity activity = getActivity();
    if (user == null || user.id <= 0 || activity == null)
        return;
    final Resources res = getResources();
    final LoaderManager lm = getLoaderManager();
    lm.destroyLoader(LOADER_ID_USER);
    lm.destroyLoader(LOADER_ID_FRIENDSHIP);
    final boolean userIsMe = user.account_id == user.id;
    mCardContent.setVisibility(View.VISIBLE);
    mErrorRetryContainer.setVisibility(View.GONE);
    mProgressContainer.setVisibility(View.GONE);
    mUser = user;
    final int userColor = getUserColor(activity, user.id, true);
    mProfileImageView.setBorderColor(userColor != 0 ? userColor : Color.WHITE);
    mProfileNameContainer.drawEnd(getAccountColor(activity, user.account_id));
    final String nick = getUserNickname(activity, user.id, true);
    mNameView.setText(
            TextUtils.isEmpty(nick) ? user.name : getString(R.string.name_with_nickname, user.name, nick));
    final int typeIconRes = getUserTypeIconRes(user.is_verified, user.is_protected);
    if (typeIconRes != 0) {
        mProfileTypeView.setImageResource(typeIconRes);
        mProfileTypeView.setVisibility(View.VISIBLE);
    } else {
        mProfileTypeView.setImageDrawable(null);
        mProfileTypeView.setVisibility(View.GONE);
    }

    mScreenNameView.setText("@" + user.screen_name);
    mDescriptionContainer.setVisibility(isEmpty(user.description_html) ? View.GONE : View.VISIBLE);
    mDescriptionView.setText(
            user.description_html != null ? Html.fromHtml(user.description_html) : user.description_plain);
    final FiretweetLinkify linkify = new FiretweetLinkify(this);
    linkify.applyAllLinks(mDescriptionView, user.account_id, false);
    mDescriptionView.setMovementMethod(null);
    mLocationContainer.setVisibility(isEmpty(user.location) ? View.GONE : View.VISIBLE);
    mLocationView.setText(user.location);
    mURLContainer.setVisibility(isEmpty(user.url) && isEmpty(user.url_expanded) ? View.GONE : View.VISIBLE);
    mURLView.setText(isEmpty(user.url_expanded) ? user.url : user.url_expanded);
    mURLView.setMovementMethod(null);
    final String createdAt = formatToLongTimeString(activity, user.created_at);
    final float daysSinceCreation = (System.currentTimeMillis() - user.created_at) / 1000 / 60 / 60 / 24;
    final int dailyTweets = Math.round(user.statuses_count / Math.max(1, daysSinceCreation));
    mCreatedAtView.setText(res.getQuantityString(R.plurals.created_at_with_N_tweets_per_day, dailyTweets,
            createdAt, dailyTweets));
    mListedCount.setText(getLocalizedNumber(mLocale, user.listed_count));
    mFollowersCount.setText(getLocalizedNumber(mLocale, user.followers_count));
    mFriendsCount.setText(getLocalizedNumber(mLocale, user.friends_count));

    mProfileImageLoader.displayProfileImage(mProfileImageView,
            getOriginalTwitterProfileImage(user.profile_image_url));
    if (userColor != 0) {
        setUserUiColor(userColor);
    } else {
        setUserUiColor(user.link_color);
    }
    final int defWidth = res.getDisplayMetrics().widthPixels;
    final int width = mBannerWidth > 0 ? mBannerWidth : defWidth;
    mProfileImageLoader.displayProfileBanner(mProfileBannerView, user.profile_banner_url, width);
    mUuckyFooter.setVisibility(isUucky(user.id, user.screen_name, user) ? View.VISIBLE : View.GONE);
    final Relationship relationship = mRelationship;
    if (relationship == null || relationship.getTargetUserId() != user.id) {
        getFriendship();
    }
    activity.setTitle(UserColorNameUtils.getDisplayName(activity, user, true));
    updateTitleColor();
    invalidateOptionsMenu();
}

From source file:org.getlantern.firetweet.util.ContentValuesCreator.java

License:Open Source License

public static ContentValues createCachedRelationship(final Relationship relationship, final long accountId) {
    final ContentValues values = new ContentValues();
    values.put(CachedRelationships.ACCOUNT_ID, accountId);
    values.put(CachedRelationships.USER_ID, relationship.getTargetUserId());
    values.put(CachedRelationships.FOLLOWING, relationship.isSourceFollowingTarget());
    values.put(CachedRelationships.FOLLOWED_BY, relationship.isSourceFollowedByTarget());
    values.put(CachedRelationships.BLOCKING, relationship.isSourceBlockingTarget());
    values.put(CachedRelationships.BLOCKED_BY, relationship.isSourceBlockedByTarget());
    values.put(CachedRelationships.MUTING, relationship.isSourceMutingTarget());
    return values;
}

From source file:org.mariotaku.twidere.fragment.support.UserFragment.java

License:Open Source License

public void displayUser(final ParcelableUser user) {
    mUser = user;/*from  w  ww .j a  v a2  s  .c o m*/
    final FragmentActivity activity = getActivity();
    if (user == null || user.id <= 0 || activity == null)
        return;
    final Resources resources = getResources();
    final UserColorNameManager manager = UserColorNameManager.getInstance(activity);
    final LoaderManager lm = getLoaderManager();
    lm.destroyLoader(LOADER_ID_USER);
    lm.destroyLoader(LOADER_ID_FRIENDSHIP);
    final boolean userIsMe = user.account_id == user.id;
    mCardContent.setVisibility(View.VISIBLE);
    mHeaderErrorContainer.setVisibility(View.GONE);
    mProgressContainer.setVisibility(View.GONE);
    mUser = user;
    final int userColor = manager.getUserColor(user.id, true);
    mProfileImageView.setBorderColor(userColor != 0 ? userColor : Color.WHITE);
    mProfileNameContainer.drawEnd(Utils.getAccountColor(activity, user.account_id));
    final String nick = manager.getUserNickname(user.id, true);
    mNameView.setText(
            TextUtils.isEmpty(nick) ? user.name : getString(R.string.name_with_nickname, user.name, nick));
    final int typeIconRes = Utils.getUserTypeIconRes(user.is_verified, user.is_protected);
    if (typeIconRes != 0) {
        mProfileTypeView.setImageResource(typeIconRes);
        mProfileTypeView.setVisibility(View.VISIBLE);
    } else {
        mProfileTypeView.setImageDrawable(null);
        mProfileTypeView.setVisibility(View.GONE);
    }
    mScreenNameView.setText("@" + user.screen_name);
    mDescriptionContainer.setVisibility(TextUtils.isEmpty(user.description_html) ? View.GONE : View.VISIBLE);
    mDescriptionView.setText(
            user.description_html != null ? Html.fromHtml(user.description_html) : user.description_plain);
    final TwidereLinkify linkify = new TwidereLinkify(this);
    linkify.applyAllLinks(mDescriptionView, user.account_id, false);
    mDescriptionView.setMovementMethod(null);
    mLocationContainer.setVisibility(TextUtils.isEmpty(user.location) ? View.GONE : View.VISIBLE);
    mLocationView.setText(user.location);
    mURLContainer.setVisibility(
            TextUtils.isEmpty(user.url) && TextUtils.isEmpty(user.url_expanded) ? View.GONE : View.VISIBLE);
    mURLView.setText(TextUtils.isEmpty(user.url_expanded) ? user.url : user.url_expanded);
    mURLView.setMovementMethod(null);
    final String createdAt = Utils.formatToLongTimeString(activity, user.created_at);
    final float daysSinceCreation = (System.currentTimeMillis() - user.created_at) / 1000 / 60 / 60 / 24;
    final int dailyTweets = Math.round(user.statuses_count / Math.max(1, daysSinceCreation));
    mCreatedAtView.setText(resources.getQuantityString(R.plurals.created_at_with_N_tweets_per_day, dailyTweets,
            createdAt, dailyTweets));
    mListedCount.setText(Utils.getLocalizedNumber(mLocale, user.listed_count));
    mFollowersCount.setText(Utils.getLocalizedNumber(mLocale, user.followers_count));
    mFriendsCount.setText(Utils.getLocalizedNumber(mLocale, user.friends_count));

    mProfileImageLoader.displayProfileImage(mProfileImageView,
            Utils.getOriginalTwitterProfileImage(user.profile_image_url));
    if (userColor != 0) {
        setUiColor(userColor);
    } else {
        setUiColor(user.link_color);
    }
    final int defWidth = resources.getDisplayMetrics().widthPixels;
    final int width = mBannerWidth > 0 ? mBannerWidth : defWidth;
    mProfileImageLoader.displayProfileBanner(mProfileBannerView, user.profile_banner_url, width);
    mUuckyFooter.setVisibility(isUucky(user.id, user.screen_name, user) ? View.VISIBLE : View.GONE);
    final Relationship relationship = mRelationship;
    if (relationship == null || relationship.getTargetUserId() != user.id) {
        getFriendship();
    }
    activity.setTitle(manager.getDisplayName(user, mNameFirst, true));

    updateTitleAlpha();
    invalidateOptionsMenu();
    updateSubtitle();
}