Example usage for twitter4j Twitter showUserList

List of usage examples for twitter4j Twitter showUserList

Introduction

In this page you can find the example usage for twitter4j Twitter showUserList.

Prototype

UserList showUserList(long listId) throws TwitterException;

Source Link

Document

Show the specified list.

Usage

From source file:com.dwdesign.tweetings.loader.UserListMembersLoader.java

License:Open Source License

@Override
public List<ParcelableUser> getUsers() throws TwitterException {
    final Twitter twitter = getTwitter();
    if (twitter == null)
        return null;
    final PagableResponseList<User> users;
    if (mListId > 0) {
        if (mUserListId <= 0) {
            mUserListId = mListId;//from  www.  j a  v a 2s .  c  om
        }
        if (mOwnerId <= 0) {
            final UserList list = twitter.showUserList(mListId);
            final User owner = list != null ? list.getUser() : null;
            mOwnerId = owner != null ? owner.getId() : -1;
        }
        users = twitter.getUserListMembers(mListId, mCursor);
    } else {
        final UserList list = findUserList(twitter, mUserId, mScreenName, mListName);
        if (list == null)
            return null;
        if (mOwnerId <= 0) {
            final User owner = list.getUser();
            mOwnerId = owner != null ? owner.getId() : -1;
        }
        if (list != null && list.getId() > 0) {
            if (mUserListId <= 0) {
                mUserListId = list.getId();
            }
            users = twitter.getUserListMembers(list.getId(), mCursor);
        } else
            return null;
    }
    mNextCursor = users.getNextCursor();
    mPrevCursor = users.getPreviousCursor();
    final List<ParcelableUser> result = new ArrayList<ParcelableUser>();
    final int size = users.size();
    for (int i = 0; i < size; i++) {
        result.add(new ParcelableUser(users.get(i), mAccountId, (mCursor + 1) * 20 + i));
    }
    return result;
}

From source file:twitter4j.examples.list.ShowUserList.java

License:Apache License

/**
 * Usage: java twitter4j.examples.list.ShowUserList [list id]
 *
 * @param args message/*from  w w  w.j  a v a  2 s .co m*/
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.list.ShowUserList [list id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        UserList list = twitter.showUserList(Integer.parseInt(args[0]));
        System.out.println("id:" + list.getId() + ", name:" + list.getName() + ", description:"
                + list.getDescription() + ", slug:" + list.getSlug() + "");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to show the list: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.list.ShowUserListMembership.java

License:Apache License

/**
 * Usage: java twitter4j.examples.list.ShowUserListMembership [list id] [user id]
 *
 * @param args message/*w  ww . ja v a  2 s .c o  m*/
 */
public static void main(String[] args) {
    if (args.length < 2) {
        System.out.println("Usage: java twitter4j.examples.list.ShowUserListMembership [list id] [user id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        long listId = Long.parseLong(args[0]);
        UserList list = twitter.showUserList(listId);
        long userId = Integer.parseInt(args[1]);
        User user = twitter.showUser(userId);
        try {
            twitter.showUserListMembership(listId, userId);
            System.out.println("@" + user.getScreenName() + " is in the list:" + list.getName());
        } catch (TwitterException te) {
            if (te.getStatusCode() == 404) {
                System.out.println("@" + user.getScreenName() + " is not in the list:" + list.getName());
            }
        }
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to check user membership: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.list.ShowUserListSubscription.java

License:Apache License

/**
 * Usage: java twitter4j.examples.list.ShowUserListSubscription [list id] [user id]
 *
 * @param args message/*from   w ww .  j ava  2 s. c o m*/
 */
public static void main(String[] args) {
    if (args.length < 2) {
        System.out.println("Usage: java twitter4j.examples.list.ShowUserListSubscription [list id] [user id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        long listId = Long.parseLong(args[0]);
        UserList list = twitter.showUserList(listId);
        long userId = Integer.parseInt(args[1]);
        User user = twitter.showUser(userId);
        try {
            twitter.showUserListSubscription(listId, userId);
            System.out.println("@" + user.getScreenName() + " is subscribing the list:" + list.getName());
        } catch (TwitterException te) {
            if (te.getStatusCode() == 404) {
                System.out.println(
                        "@" + user.getScreenName() + " is not subscribing  the list:" + list.getName());
            }
        }
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to check user subscription: " + te.getMessage());
        System.exit(-1);
    }
}