Example usage for twitter4j Twitter getUserLists

List of usage examples for twitter4j Twitter getUserLists

Introduction

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

Prototype

ResponseList<UserList> getUserLists(String listOwnerScreenName) throws TwitterException;

Source Link

Document

List the lists of the specified user.

Usage

From source file:com.klinker.android.twitter.activities.drawer_activities.lists.ListsActivity.java

License:Apache License

public void getLists() {
    new Thread(new Runnable() {
        @Override//  ww  w.j  a v a  2  s.  c  o  m
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, settings);

                final ResponseList<UserList> lists;
                try {
                    lists = twitter.getUserLists(settings.myScreenName);
                } catch (OutOfMemoryError e) {
                    return;
                }

                Collections.sort(lists, new Comparator<UserList>() {
                    public int compare(UserList result1, UserList result2) {
                        return result1.getName().compareTo(result2.getName());
                    }
                });

                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if (lists.size() > 0) {
                            listView.setAdapter(new ListsArrayAdapter(context, lists));
                            listView.setVisibility(View.VISIBLE);
                        } else {
                            LinearLayout nothing = (LinearLayout) findViewById(R.id.no_content);
                            try {
                                nothing.setVisibility(View.VISIBLE);
                            } catch (Exception e) {

                            }
                            listView.setVisibility(View.GONE);
                        }

                        LinearLayout spinner = (LinearLayout) findViewById(R.id.list_progress);
                        spinner.setVisibility(View.GONE);
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        LinearLayout nothing = (LinearLayout) findViewById(R.id.no_content);
                        nothing.setVisibility(View.VISIBLE);
                        listView.setVisibility(View.GONE);

                        LinearLayout spinner = (LinearLayout) findViewById(R.id.list_progress);
                        spinner.setVisibility(View.GONE);
                    }
                });
            }
        }
    }).start();
}

From source file:de.vanita5.twittnuker.loader.support.UserListsLoader.java

License:Open Source License

@Override
public ResponseList<UserList> getUserLists(final Twitter twitter) throws TwitterException {
    if (twitter == null)
        return null;
    if (mUserId > 0)
        return twitter.getUserLists(mUserId);
    else if (mScreenName != null)
        return twitter.getUserLists(mScreenName);
    return null;/* w  w w  .j  a v a2 s  . c  om*/
}

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

License:Apache License

/**
 * Usage: java twitter4j.examples.list.GetUserLists [list owner screen name]
 *
 * @param args message/*from w w  w  .  ja  v  a 2 s  .  c  o  m*/
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.list.GetUserLists [list owner screen name]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        ResponseList<UserList> lists = twitter.getUserLists(args[0]);
        for (UserList list : lists) {
            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 list the lists: " + te.getMessage());
        System.exit(-1);
    }
}