Example usage for twitter4j Twitter getSuggestedUserCategories

List of usage examples for twitter4j Twitter getSuggestedUserCategories

Introduction

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

Prototype

ResponseList<Category> getSuggestedUserCategories() throws TwitterException;

Source Link

Document

Access to Twitter's suggested user list.

Usage

From source file:com.daiv.android.twitter.ui.drawer_activities.discover.people.CategoryFragment.java

License:Apache License

public void getSuggestions() {

    new Thread(new Runnable() {
        @Override//from   w  w  w . jav  a 2 s.co m
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, DrawerActivity.settings);

                int i = 0;

                final ResponseList<Category> categories = twitter.getSuggestedUserCategories();

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

                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        listView.setAdapter(new CategoriesArrayAdapter(context, categories));
                        listView.setVisibility(View.VISIBLE);

                        LinearLayout spinner = (LinearLayout) layout.findViewById(R.id.list_progress);
                        spinner.setVisibility(View.GONE);
                    }
                });
            } catch (Throwable e) {
                e.printStackTrace();
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(context, getResources().getString(R.string.no_location),
                                Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();
}

From source file:twitter4j.examples.suggestedusers.GetSuggestedUserCategories.java

License:Apache License

/**
 * Usage: java twitter4j.examples.suggestedusers.GetSuggestedUserCategories
 *
 * @param args message// w w w . j  a  v a 2  s.c o m
 */
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        System.out.println("Showing suggested user categories.");
        ResponseList<Category> categories = twitter.getSuggestedUserCategories();
        for (Category category : categories) {
            System.out.println(category.getName() + ":" + category.getSlug());
        }
        System.out.println("done.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get suggested categories: " + te.getMessage());
        System.exit(-1);
    }
}