Search in sources :

Example 1 with SavedSearchArrayAdapter

use of com.klinker.android.twitter.adapters.SavedSearchArrayAdapter 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)

Aggregations

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