Example usage for twitter4j Relationship isSourceMutingTarget

List of usage examples for twitter4j Relationship isSourceMutingTarget

Introduction

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

Prototype

boolean isSourceMutingTarget();

Source Link

Document

Returns id the source user is muting the target user

Usage

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

License:Apache License

protected int setupDefaultUserInfoTimeline() throws TwitterException {
    final User loginUser = getLoginUser();
    final ResponseList<Status> responseList = createDefaultResponseList(loginUser);
    this.responseList = responseList;
    final ResponseList<Status> emptyStatusResponseList = createResponseList();

    final int size = responseList.size();
    when(loginUser.getStatusesCount()).thenReturn(size);
    when(twitter.getUserTimeline(loginUser.getId())).thenReturn(responseList);
    when(twitter.getUserTimeline(anyLong(), any(Paging.class))).thenReturn(emptyStatusResponseList);
    when(twitter.getFavorites(anyLong())).thenReturn(emptyStatusResponseList);
    final PagableResponseList<User> emptyUserPagableResponseList = mock(PagableResponseList.class);
    when(twitter.getFollowersList(anyLong(), anyLong())).thenReturn(emptyUserPagableResponseList);
    when(twitter.getFriendsList(anyLong(), anyLong())).thenReturn(emptyUserPagableResponseList);

    final Relationship relationship = mock(Relationship.class);
    when(relationship.isSourceFollowingTarget()).thenReturn(true);
    when(relationship.isSourceMutingTarget()).thenReturn(false);
    when(twitter.showFriendship(anyLong(), anyLong())).thenReturn(relationship);
    return responseList.size();
}

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

License:Apache License

public void bindRelationship(Relationship relationship) {
    if (relationship.isSourceFollowingTarget()) {
        bindFollowingStatus(R.string.user_following, R.color.twitter_primary);
    } else if (relationship.isSourceBlockingTarget()) {
        bindFollowingStatus(R.string.user_blocking, R.color.twitter_muted);
    } else {/*w  w w .  jav  a  2 s .  c om*/
        followingStatus.setVisibility(GONE);
    }
    mutedStatus.setVisibility(relationship.isSourceMutingTarget() ? VISIBLE : GONE);
}

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

License:Open Source License

@Override
public void onPrepareOptionsMenu(final Menu menu) {
    if (!shouldUseNativeMenu() || !menu.hasVisibleItems())
        return;//from   w  w w  . j av a2  s. c  om
    final AsyncTwitterWrapper twitter = getTwitterWrapper();
    final ParcelableUser user = getUser();
    final Relationship relationship = mRelationship;
    if (twitter == null || user == null)
        return;
    final boolean isMyself = user.account_id == user.id;
    final MenuItem mentionItem = menu.findItem(MENU_MENTION);
    if (mentionItem != null) {
        mentionItem.setTitle(
                getString(R.string.mention_user_name, UserColorNameUtils.getDisplayName(getActivity(), user)));
    }
    Utils.setMenuItemAvailability(menu, MENU_MENTION, !isMyself);
    Utils.setMenuItemAvailability(menu, R.id.incoming_friendships, isMyself);
    //        final MenuItem followItem = menu.findItem(MENU_FOLLOW);
    //        followItem.setVisible(!isMyself);
    //        final boolean shouldShowFollowItem = !creatingFriendship && !destroyingFriendship && !isMyself
    //                && relationship != null;
    //        followItem.setEnabled(shouldShowFollowItem);
    //        if (shouldShowFollowItem) {
    //            followItem.setTitle(isFollowing ? R.string.unfollow : isProtected ? R.string.send_follow_request
    //                    : R.string.follow);
    //            followItem.setIcon(isFollowing ? R.drawable.ic_action_cancel : R.drawable.ic_action_add);
    //        } else {
    //            followItem.setTitle(null);
    //            followItem.setIcon(null);
    //        }
    if (!isMyself && relationship != null) {
        setMenuItemAvailability(menu, MENU_SEND_DIRECT_MESSAGE, relationship.canSourceDMTarget());
        setMenuItemAvailability(menu, MENU_BLOCK, true);
        setMenuItemAvailability(menu, MENU_MUTE_USER, true);
        final MenuItem blockItem = menu.findItem(MENU_BLOCK);
        if (blockItem != null) {
            final boolean blocking = relationship.isSourceBlockingTarget();
            ActionIconDrawable.setMenuHighlight(blockItem, new FiretweetMenuInfo(blocking));
            blockItem.setTitle(blocking ? R.string.unblock : R.string.block);
        }
        final MenuItem muteItem = menu.findItem(MENU_MUTE_USER);
        if (muteItem != null) {
            final boolean muting = relationship.isSourceMutingTarget();
            ActionIconDrawable.setMenuHighlight(muteItem, new FiretweetMenuInfo(muting));
            muteItem.setTitle(muting ? R.string.unmute : R.string.mute);
        }
        final MenuItem filterItem = menu.findItem(MENU_ADD_TO_FILTER);
        if (filterItem != null) {
            final boolean filtering = Utils.isFilteringUser(getActivity(), user.id);
            ActionIconDrawable.setMenuHighlight(filterItem, new FiretweetMenuInfo(filtering));
            filterItem.setTitle(filtering ? R.string.remove_from_filter : R.string.add_to_filter);
        }
    } else {
        setMenuItemAvailability(menu, MENU_SEND_DIRECT_MESSAGE, false);
        setMenuItemAvailability(menu, MENU_BLOCK, false);
        setMenuItemAvailability(menu, MENU_MUTE_USER, false);
        setMenuItemAvailability(menu, MENU_REPORT_SPAM, false);
    }
    setMenuItemAvailability(menu, R.id.muted_users, isMyself);
    setMenuItemAvailability(menu, R.id.blocked_users, isMyself);
    final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER);
    final Bundle extras = new Bundle();
    extras.putParcelable(EXTRA_USER, user);
    intent.putExtras(extras);
    menu.removeGroup(MENU_GROUP_USER_EXTENSION);
    addIntentToMenu(getActivity(), menu, intent, MENU_GROUP_USER_EXTENSION);
}

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

@Override
public void onPrepareOptionsMenu(final Menu menu) {
    final AsyncTwitterWrapper twitter = getTwitterWrapper();
    final ParcelableUser user = getUser();
    final Relationship relationship = mRelationship;
    if (twitter == null || user == null)
        return;/*from   w w w .j ava 2 s . com*/
    final boolean isMyself = user.account_id == user.id;
    final MenuItem mentionItem = menu.findItem(MENU_MENTION);
    if (mentionItem != null) {
        final String displayName = mUserColorNameManager.getDisplayName(user, mNameFirst, true);
        mentionItem.setTitle(getString(R.string.mention_user_name, displayName));
    }
    MenuUtils.setMenuItemAvailability(menu, MENU_MENTION, !isMyself);
    MenuUtils.setMenuItemAvailability(menu, R.id.incoming_friendships, isMyself);
    MenuUtils.setMenuItemAvailability(menu, R.id.saved_searches, isMyself);
    //        final MenuItem followItem = menu.findItem(MENU_FOLLOW);
    //        followItem.setVisible(!isMyself);
    //        final boolean shouldShowFollowItem = !creatingFriendship && !destroyingFriendship && !isMyself
    //                && relationship != null;
    //        followItem.setEnabled(shouldShowFollowItem);
    //        if (shouldShowFollowItem) {
    //            followItem.setTitle(isFollowing ? R.string.unfollow : isProtected ? R.string.send_follow_request
    //                    : R.string.follow);
    //            followItem.setIcon(isFollowing ? R.drawable.ic_action_cancel : R.drawable.ic_action_add);
    //        } else {
    //            followItem.setTitle(null);
    //            followItem.setIcon(null);
    //        }
    if (!isMyself && relationship != null) {
        MenuUtils.setMenuItemAvailability(menu, MENU_SEND_DIRECT_MESSAGE, relationship.canSourceDMTarget());
        MenuUtils.setMenuItemAvailability(menu, MENU_BLOCK, true);
        MenuUtils.setMenuItemAvailability(menu, MENU_MUTE_USER, true);
        final MenuItem blockItem = menu.findItem(MENU_BLOCK);
        if (blockItem != null) {
            final boolean blocking = relationship.isSourceBlockingTarget();
            ActionIconDrawable.setMenuHighlight(blockItem, new TwidereMenuInfo(blocking));
            blockItem.setTitle(blocking ? R.string.unblock : R.string.block);
        }
        final MenuItem muteItem = menu.findItem(MENU_MUTE_USER);
        if (muteItem != null) {
            final boolean muting = relationship.isSourceMutingTarget();
            ActionIconDrawable.setMenuHighlight(muteItem, new TwidereMenuInfo(muting));
            muteItem.setTitle(muting ? R.string.unmute : R.string.mute);
        }
        final MenuItem filterItem = menu.findItem(MENU_ADD_TO_FILTER);
        if (filterItem != null) {
            final boolean filtering = Utils.isFilteringUser(getActivity(), user.id);
            ActionIconDrawable.setMenuHighlight(filterItem, new TwidereMenuInfo(filtering));
            filterItem.setTitle(filtering ? R.string.remove_from_filter : R.string.add_to_filter);
        }
    } else {
        MenuUtils.setMenuItemAvailability(menu, MENU_SEND_DIRECT_MESSAGE, false);
        MenuUtils.setMenuItemAvailability(menu, MENU_BLOCK, false);
        MenuUtils.setMenuItemAvailability(menu, MENU_MUTE_USER, false);
        MenuUtils.setMenuItemAvailability(menu, MENU_REPORT_SPAM, false);
    }
    MenuUtils.setMenuItemAvailability(menu, R.id.muted_users, isMyself);
    MenuUtils.setMenuItemAvailability(menu, R.id.blocked_users, isMyself);
    final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_USER);
    final Bundle extras = new Bundle();
    extras.putParcelable(EXTRA_USER, user);
    intent.putExtras(extras);
    menu.removeGroup(MENU_GROUP_USER_EXTENSION);
    Utils.addIntentToMenu(getActivity(), menu, intent, MENU_GROUP_USER_EXTENSION);
}