Search in sources :

Example 1 with ListsArrayAdapter

use of com.klinker.android.twitter.adapters.ListsArrayAdapter in project Talon-for-Twitter by klinker24.

the class ListsActivity method getLists.

public void getLists() {
    new Thread(new Runnable() {

        @Override
        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();
}
Also used : Twitter(twitter4j.Twitter) DrawerActivity(com.klinker.android.twitter.activities.drawer_activities.DrawerActivity) LoginActivity(com.klinker.android.twitter.activities.setup.LoginActivity) Activity(android.app.Activity) UserList(twitter4j.UserList) ListsArrayAdapter(com.klinker.android.twitter.adapters.ListsArrayAdapter) LinearLayout(android.widget.LinearLayout)

Aggregations

Activity (android.app.Activity)1 LinearLayout (android.widget.LinearLayout)1 DrawerActivity (com.klinker.android.twitter.activities.drawer_activities.DrawerActivity)1 LoginActivity (com.klinker.android.twitter.activities.setup.LoginActivity)1 ListsArrayAdapter (com.klinker.android.twitter.adapters.ListsArrayAdapter)1 Twitter (twitter4j.Twitter)1 UserList (twitter4j.UserList)1