Search in sources :

Example 1 with SavedSearch

use of twitter4j.SavedSearch in project twitter4j by yusuke.

the class CreateSavedSearch method main.

/**
     * Usage: java twitter4j.examples.savedsearches.CreateSavedSearch [query]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.savedsearches.CreateSavedSearch [query]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        SavedSearch savedSearch = twitter.createSavedSearch(args[0]);
        System.out.println("Successfully created saved search [name:" + savedSearch.getName() + " query:" + savedSearch.getQuery() + " id:" + savedSearch.getId() + "]");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to create a saved search: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : SavedSearch(twitter4j.SavedSearch) Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 2 with SavedSearch

use of twitter4j.SavedSearch in project twitter4j by yusuke.

the class ShowSavedSearch method main.

/**
     * Usage: java twitter4j.examples.savedsearches.ShowSavedSearch [saved search id]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.savedsearches.ShowSavedSearch [saved search id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        SavedSearch savedSearch = twitter.showSavedSearch(Integer.parseInt(args[0]));
        System.out.println("[name:" + savedSearch.getName() + " query:" + savedSearch.getQuery() + " id:" + savedSearch.getId() + "]");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get the saved search: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : SavedSearch(twitter4j.SavedSearch) Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 3 with SavedSearch

use of twitter4j.SavedSearch in project Talon-for-Twitter by klinker24.

the class SavedSearchesActivity method getSearches.

public static void getSearches() {
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, settings);
                final ResponseList<SavedSearch> searches = twitter.getSavedSearches();
                Collections.sort(searches, new Comparator<SavedSearch>() {

                    public int compare(SavedSearch result1, SavedSearch result2) {
                        return result1.getQuery().compareTo(result2.getQuery());
                    }
                });
                final ArrayList<String> searchNames = new ArrayList<String>();
                for (SavedSearch sear : searches) {
                    searchNames.add(sear.getQuery());
                }
                ((Activity) context).runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        if (searchNames.size() > 0) {
                            adapter = new SavedSearchArrayAdapter(context, searchNames);
                            listView.setAdapter(adapter);
                            listView.setVisibility(View.VISIBLE);
                        } else {
                            try {
                                nothing.setVisibility(View.VISIBLE);
                            } catch (Exception e) {
                            }
                            listView.setVisibility(View.GONE);
                        }
                        spinner.setVisibility(View.GONE);
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
                ((Activity) context).runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        spinner.setVisibility(View.GONE);
                    }
                });
            }
        }
    }).start();
}
Also used : SavedSearch(twitter4j.SavedSearch) ArrayList(java.util.ArrayList) Twitter(twitter4j.Twitter) Activity(android.app.Activity) SavedSearchArrayAdapter(com.klinker.android.twitter.adapters.SavedSearchArrayAdapter)

Example 4 with SavedSearch

use of twitter4j.SavedSearch in project twitter4j by yusuke.

the class DestroySavedSearch method main.

/**
     * Usage: java twitter4j.examples.savedsearches.DestroySavedSearch [saved search id]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.savedsearches.DestroySavedSearch [saved search id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        SavedSearch savedSearch = twitter.destroySavedSearch(Integer.parseInt(args[0]));
        System.out.println("Successfully deleted saved search [name:" + savedSearch.getName() + " query:" + savedSearch.getQuery() + " id:" + savedSearch.getId() + "]");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to delete the saved search: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : SavedSearch(twitter4j.SavedSearch) Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 5 with SavedSearch

use of twitter4j.SavedSearch in project twitter4j by yusuke.

the class GetSavedSearches method main.

/**
     * Usage: java twitter4j.examples.savedsearches.GetSavedSearches
     *
     * @param args message
     */
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        List<SavedSearch> savedSearches = twitter.getSavedSearches();
        for (SavedSearch savedSearch : savedSearches) {
            System.out.println("[name:" + savedSearch.getName() + " query:" + savedSearch.getQuery() + " id:" + savedSearch.getId() + "]");
        }
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to retrieve saved searches: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : SavedSearch(twitter4j.SavedSearch) Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Aggregations

SavedSearch (twitter4j.SavedSearch)5 Twitter (twitter4j.Twitter)5 TwitterException (twitter4j.TwitterException)4 TwitterFactory (twitter4j.TwitterFactory)4 Activity (android.app.Activity)1 SavedSearchArrayAdapter (com.klinker.android.twitter.adapters.SavedSearchArrayAdapter)1 ArrayList (java.util.ArrayList)1