Search in sources :

Example 16 with TimelineArrayAdapter

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

the class ChoosenListActivity method onRefreshStarted.

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

        @Override
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, settings);
                paging.setPage(1);
                ResponseList<twitter4j.Status> lists = twitter.getUserListStatuses(listId, paging);
                statuses.clear();
                for (Status status : lists) {
                    statuses.add(status);
                }
                ((Activity) context).runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        adapter = new TimelineArrayAdapter(context, statuses);
                        listView.setAdapter(adapter);
                        listView.setVisibility(View.VISIBLE);
                        spinner.setVisibility(View.GONE);
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
            } catch (OutOfMemoryError e) {
                e.printStackTrace();
            }
            ((Activity) context).runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    mPullToRefreshLayout.setRefreshing(false);
                }
            });
        }
    }).start();
}
Also used : Status(twitter4j.Status) Twitter(twitter4j.Twitter) LoginActivity(com.klinker.android.twitter.activities.setup.LoginActivity) Activity(android.app.Activity) TimelineArrayAdapter(com.klinker.android.twitter.adapters.TimelineArrayAdapter)

Example 17 with TimelineArrayAdapter

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

the class ChoosenListActivity method getLists.

public void getLists() {
    canRefresh = false;
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, settings);
                ResponseList<twitter4j.Status> lists = twitter.getUserListStatuses(listId, paging);
                paging.setPage(paging.getPage() + 1);
                for (Status status : lists) {
                    statuses.add(status);
                }
                ((Activity) context).runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        if (adapter == null) {
                            adapter = new TimelineArrayAdapter(context, statuses);
                            listView.setAdapter(adapter);
                            listView.setVisibility(View.VISIBLE);
                        } else {
                            adapter.notifyDataSetChanged();
                        }
                        spinner.setVisibility(View.GONE);
                        canRefresh = true;
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
                ((Activity) context).runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        spinner.setVisibility(View.GONE);
                        canRefresh = false;
                    }
                });
            } catch (OutOfMemoryError e) {
                e.printStackTrace();
                ((Activity) context).runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        spinner.setVisibility(View.GONE);
                        canRefresh = false;
                    }
                });
            }
        }
    }).start();
}
Also used : Status(twitter4j.Status) Twitter(twitter4j.Twitter) LoginActivity(com.klinker.android.twitter.activities.setup.LoginActivity) Activity(android.app.Activity) TimelineArrayAdapter(com.klinker.android.twitter.adapters.TimelineArrayAdapter)

Aggregations

TimelineArrayAdapter (com.klinker.android.twitter.adapters.TimelineArrayAdapter)17 Status (twitter4j.Status)16 Twitter (twitter4j.Twitter)16 Activity (android.app.Activity)14 Query (twitter4j.Query)8 QueryResult (twitter4j.QueryResult)8 LinearLayout (android.widget.LinearLayout)4 LoginActivity (com.klinker.android.twitter.activities.setup.LoginActivity)4 ArrayList (java.util.ArrayList)4 TwitterException (twitter4j.TwitterException)4 View (android.view.View)2 AbsListView (android.widget.AbsListView)2 MainActivity (com.klinker.android.twitter.activities.MainActivity)2 ComposeActivity (com.klinker.android.twitter.activities.compose.ComposeActivity)2 SettingsActivity (com.klinker.android.twitter.settings.SettingsActivity)2 AsyncListView (org.lucasr.smoothie.AsyncListView)2 Context (android.content.Context)1 PackageManager (android.content.pm.PackageManager)1 Resources (android.content.res.Resources)1 Location (android.location.Location)1