Example usage for twitter4j Twitter getRetweetsOfMe

List of usage examples for twitter4j Twitter getRetweetsOfMe

Introduction

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

Prototype

ResponseList<Status> getRetweetsOfMe(Paging paging) throws TwitterException;

Source Link

Document

Returns the 20 most recent tweets of the authenticated user that have been retweeted by others.

Usage

From source file:com.klinker.android.twitter.activities.drawer_activities.RetweetActivity.java

License:Apache License

public void getRetweets() {
    if (!hasMore) {
        return;/*w ww. j  a v a  2  s .  c  om*/
    }

    canRefresh = false;
    final LinearLayout spinner = (LinearLayout) findViewById(R.id.list_progress);

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

                final ResponseList<twitter4j.Status> favs = twitter.getRetweetsOfMe(paging);

                if (favs.size() < 17) {
                    hasMore = false;
                }

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

                for (twitter4j.Status s : favs) {
                    statuses.add(s);
                }

                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {

                        if (adapter == null) {
                            if (statuses.size() > 0) {
                                adapter = new TimelineArrayAdapter(context, statuses,
                                        TimelineArrayAdapter.RETWEET);
                                listView.setAdapter(adapter);
                                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);
                            }
                        } 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();
}

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

License:Open Source License

@Override
protected ResponseList<Status> getStatuses(final Twitter twitter, final Paging paging) throws TwitterException {
    if (twitter == null)
        return null;
    final ResponseList<Status> statuses = twitter.getRetweetsOfMe(paging);
    if (mTotalItemsCount == -1 && !statuses.isEmpty()) {
        final User user = statuses.get(0).getUser();
        if (user != null) {
            mTotalItemsCount = user.getStatusesCount();
        }/*from   w  ww.  j  a  v a  2 s  . c o  m*/
    }
    return statuses;
}

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

License:Open Source License

@NonNull
@Override//from w  w w  . j  a  v a2  s . c o m
protected ResponseList<Status> getStatuses(@NonNull final Twitter twitter, final Paging paging)
        throws TwitterException {
    if (twitter == null)
        return null;
    final ResponseList<Status> statuses = twitter.getRetweetsOfMe(paging);
    if (mTotalItemsCount == -1 && !statuses.isEmpty()) {
        final User user = statuses.get(0).getUser();
        if (user != null) {
            mTotalItemsCount = user.getStatusesCount();
        }
    }
    return statuses;
}

From source file:org.wso2.carbon.connector.twitter.TwitterRetweetsofMine.java

License:Open Source License

@Override
public void connect(MessageContext messageContext) throws ConnectException {
    if (log.isDebugEnabled()) {
        log.info("executing twitter get user time line");
    }/*from www. ja  v a2 s  .  c  om*/

    try {
        String page = TwitterUtils.lookupTemplateParamater(messageContext, PAGE);

        Twitter twitter = new TwitterClientLoader(messageContext).loadApiClient();

        List<Status> results = null;
        if (page != null && !page.isEmpty()) {
            results = twitter.getRetweetsOfMe(new Paging(Long.parseLong(page)));
        } else {
            results = twitter.getRetweetsOfMe();
        }
        OMElement element = this.performSearch(results);

        super.preparePayload(messageContext, element);

    } catch (TwitterException te) {
        log.error("Failed to search twitter : " + te.getMessage(), te);
        TwitterUtils.storeErrorResponseStatus(messageContext, te);
    } catch (Exception te) {
        log.error("Failed to search generic: " + te.getMessage(), te);
        TwitterUtils.storeErrorResponseStatus(messageContext, te);
    }
}