Example usage for twitter4j Twitter getFavorites

List of usage examples for twitter4j Twitter getFavorites

Introduction

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

Prototype

ResponseList<Status> getFavorites(long userId, Paging paging) throws TwitterException;

Source Link

Document

Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.

Usage

From source file:com.daiv.android.twitter.ui.profile_viewer.fragments.sub_fragments.ProfileFavoritesFragment.java

License:Apache License

public void doSearch() {
    spinner.setVisibility(View.VISIBLE);

    new Thread(new Runnable() {
        @Override/*w  w  w.ja  v a 2  s  .c  o  m*/
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, settings);

                ResponseList<Status> result;
                try {
                    result = twitter.getFavorites(screenName, paging);
                } catch (OutOfMemoryError e) {
                    return;
                }

                tweets.clear();

                for (twitter4j.Status status : result) {
                    tweets.add(status);
                }

                hasMore = result.size() > 17;

                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        adapter = new TimelineArrayAdapter(context, tweets);
                        listView.setAdapter(adapter);
                        listView.setVisibility(View.VISIBLE);

                        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;
                    }
                });

            }

        }
    }).start();
}

From source file:com.daiv.android.twitter.ui.profile_viewer.fragments.sub_fragments.ProfileFavoritesFragment.java

License:Apache License

public void getMore() {
    canRefresh = false;/* w w  w .  jav a  2s .c o m*/

    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, settings);

                paging.setPage(paging.getPage() + 1);

                ResponseList<Status> result = twitter.getFavorites(screenName, paging);

                for (twitter4j.Status status : result) {
                    tweets.add(status);
                }

                hasMore = result.size() > 17;

                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        adapter.notifyDataSetChanged();
                        canRefresh = true;
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        canRefresh = false;
                        hasMore = false;
                    }
                });

            }

        }
    }).start();
}

From source file:com.klinker.android.twitter.activities.profile_viewer.fragments.sub_fragments.ProfileFavoritesFragment.java

License:Apache License

public void doSearch() {
    spinner.setVisibility(View.VISIBLE);

    new Thread(new Runnable() {
        @Override/* w w w. j a va  2  s  . c  om*/
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, settings);

                ResponseList<Status> result;
                try {
                    result = twitter.getFavorites(screenName, paging);
                } catch (OutOfMemoryError e) {
                    return;
                }

                tweets.clear();

                for (twitter4j.Status status : result) {
                    tweets.add(status);
                }

                if (result.size() > 17) {
                    hasMore = true;
                } else {
                    hasMore = false;
                }

                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        adapter = new TimelineArrayAdapter(context, tweets);
                        listView.setAdapter(adapter);
                        listView.setVisibility(View.VISIBLE);

                        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;
                    }
                });

            }

        }
    }).start();
}

From source file:com.klinker.android.twitter.activities.profile_viewer.fragments.sub_fragments.ProfileFavoritesFragment.java

License:Apache License

public void getMore() {
    canRefresh = false;/*from  www  . j a va 2  s.  co  m*/

    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, settings);

                paging.setPage(paging.getPage() + 1);

                ResponseList<Status> result = twitter.getFavorites(screenName, paging);

                for (twitter4j.Status status : result) {
                    tweets.add(status);
                }

                if (result.size() > 17) {
                    hasMore = true;
                } else {
                    hasMore = false;
                }

                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        adapter.notifyDataSetChanged();
                        canRefresh = true;
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        canRefresh = false;
                        hasMore = false;
                    }
                });

            }

        }
    }).start();
}

From source file:de.vanita5.twittnuker.loader.support.UserFavoritesLoader.java

License:Open Source License

@Override
public ResponseList<Status> getStatuses(final Twitter twitter, final Paging paging) throws TwitterException {
    if (twitter == null)
        return null;
    if (mUserId != -1)
        return twitter.getFavorites(mUserId, paging);
    else if (mUserScreenName != null)
        return twitter.getFavorites(mUserScreenName, paging);
    return null;/*from w w  w  .j  a va 2s. c  o  m*/
}

From source file:org.getlantern.firetweet.loader.support.UserFavoritesLoader.java

License:Open Source License

@NonNull
@Override/*from   w  ww . ja va  2s  . co  m*/
public ResponseList<Status> getStatuses(@NonNull final Twitter twitter, final Paging paging)
        throws TwitterException {
    if (twitter == null)
        return null;
    if (mUserId != -1)
        return twitter.getFavorites(mUserId, paging);
    else if (mUserScreenName != null)
        return twitter.getFavorites(mUserScreenName, paging);
    return null;
}