Example usage for twitter4j Twitter showStatus

List of usage examples for twitter4j Twitter showStatus

Introduction

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

Prototype

Status showStatus(long id) throws TwitterException;

Source Link

Document

Returns a single status, specified by the id parameter below.

Usage

From source file:DumpRetrievedTweet.java

private void GetTweetData() throws TwitterException, IOException {
    System.out.println("Seting up twitter");
    Twitter twitter = new TwitterFactory().getInstance();
    //        String CONSUMER_KEY = "9zVRlQTXlTKf4QeYMiucyXqg9";
    //        String CONSUMER_SECRET = "xH0H2SfcXj914z1DGB7HgZZ012ntSqRbfnLFw5A6v1TB94Y2O1";
    //        String TWITTER_TOKEN = "753222147695259648-QnzInB98PtwpFb75dqlP1J7SSOQMcMX";
    //        String TWITTER_TOKEN_SECRET = "uxJHGE1e2kFBJYoNRRFfy5gBLXYaRrzCUycRncSkoLsle";

    //        String CONSUMER_KEY = "nNV9KxWFVmdI0a2shhJImcEGk";
    //        String CONSUMER_SECRET = "I4AvaGOZRFtLFTqAkpKrfFOnV13Ej2seiwnNQ47z0qE9ORoBhW";
    //        String TWITTER_TOKEN = "753222147695259648-kY3Gq1O6FqHw6LQViuTQAhLbEQLZRZX";
    //        String TWITTER_TOKEN_SECRET = "a6hsmYipeGvqJcrIUUZah4ZhH7B8wbY77hqNWwojQysiO";

    //        String CONSUMER_KEY = "PBMKK9P2YD9MFgDfdANQt2Zzc";
    //        String CONSUMER_SECRET = "ldB0FybCQIjfYLzuYE4CeGtvcevaSkFxPENGbFd19Yn2crXa5R";
    //        String TWITTER_TOKEN = "753222147695259648-ZWqj3CvdQAXeVl9zfa71BCRcxeD2yAi";
    //        String TWITTER_TOKEN_SECRET = "1bypYSL1D1t1Gt6nQLwEbyRg5rniOUHfJhTYuVWYWvAvP";

    //        String CONSUMER_KEY = "tf0Cbp3ZQcJh9vwkQ9vInw6WS";
    //        String CONSUMER_SECRET = "gRmcjuqrSH40K47CkRFEO5OVthUtExEW7xrZU2oWiRcpPmzRz9";
    //        String TWITTER_TOKEN = "126239739-qaXgO4urp91PXLT2RgkxlyONwAQyXnq236dhqtTe";
    //        String TWITTER_TOKEN_SECRET = "AIykIeAKGFHRucTPgNYZd9bqdbZEJQhMsF5cGiyBLUII7";

    String CONSUMER_KEY = "EmmSsTEML5XrB3SYBUOOKxqn6";
    String CONSUMER_SECRET = "J1TrjmcqhBd1cURBTjUCwNqcf5IxCfdInAs74TVT9axvSwLnlJ";
    String TWITTER_TOKEN = "126239739-ktoaE8NhM4S9CjFhrktTdpuvY7fkbqj1nYxfaQsD";
    String TWITTER_TOKEN_SECRET = "a5fFQbKO9meoqnY31wwlZF0nqDHtqfxlwUla1uaAT8Y0p";

    twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
    AccessToken accesstoken = new AccessToken(TWITTER_TOKEN, TWITTER_TOKEN_SECRET);
    twitter.setOAuthAccessToken(accesstoken);
    writer.write("\n");
    for (int i = 0; i < tweet_ids.size(); i++) {
        Long tweet_id = tweet_ids.get(i);
        System.out.println("[" + i + "] Getting Tweet id " + tweet_id);
        Status status = twitter.showStatus((long) tweet_ids.get(i));
        if (status == null) {
            System.out.println("[FAILED] Doesnot exist twitter with tweet id : " + tweet_id);
        } else {/*  w  w w  .ja v a  2 s.c o  m*/
            System.out.println("status asli : " + status.getText());
            writer.write(tweet_id + "\t" + status.getText().replaceAll("\n", " "));
            writer.write("\n");
            updateIsLabelledAnotator3(tweet_id);
        }
    }
}

From source file:MyUpdateTweetTimeToDB.java

public void GetTweetTime() {
    Twitter twitter = new TwitterFactory().getInstance();
    String CONSUMER_KEY = "4enxNevEGWMqBuKzcJoQ";
    String CONSUMER_SECRET = "UUDCNSvkFoZRaRUV4b8eHBcgR2N1LSrHXX7IELxdIk";
    String TWITTER_TOKEN = "470084145-qwjAlIxq7GFB1I62TO5ebyoO10tXgUuZJfgTLu7G";
    String TWITTER_TOKEN_SECRET = "9y47ww1xk0Nc5DhL9ZW0HOC6Qoig2wP101tOjsERnqNNv";
    twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
    AccessToken accesstoken = new AccessToken(TWITTER_TOKEN, TWITTER_TOKEN_SECRET);
    twitter.setOAuthAccessToken(accesstoken);

    Iterator iterator = tweet_id_to_time.entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry pair = (Map.Entry) iterator.next();
        try {/*from   ww  w  . j ava2s  .c  o m*/
            Status status = twitter.showStatus((long) pair.getKey());
            if (status == null) {
                System.out.println("Doesnot exist twitter with tweet id : " + pair.getKey());
            } else {
                tweet_id_to_time.put((Long) pair.getKey(), status.getCreatedAt().getTime());
            }
        } catch (TwitterException e) {
            tweet_id_to_time.put((Long) pair.getKey(), 1L);
            e.printStackTrace();
        }
        System.out.println("Id : " + pair.getKey() + "value " + pair.getValue());
    }
}

From source file:com.alainesp.fan.sanderson.SummaryFragment.java

License:Open Source License

protected int doWork() {
    int state = DownloadParseSaveTask.STATE_SUCCESS;

    try {/*w  w  w .  ja  va2s  . c om*/
        List<twitter4j.Status> tweets;

        // Twitter client configuration
        ConfigurationBuilder builder = new ConfigurationBuilder();
        builder.setOAuthConsumerKey(TwitterAPISecrets.CONSUMER_KEY)
                .setOAuthConsumerSecret(TwitterAPISecrets.CONSUMER_SECRET);
        // TODO: Use guest authentication instead of application
        builder.setApplicationOnlyAuthEnabled(true).setDebugEnabled(false).setGZIPEnabled(true);

        Twitter twitter = new TwitterFactory(builder.build()).getInstance();
        twitter.getOAuth2Token();

        // Get the tweets
        long lastTweetID = DB.Tweet.getLastTweetID();
        if (lastTweetID <= 0)
            tweets = twitter.getUserTimeline("BrandSanderson");
        else
            tweets = twitter.getUserTimeline("BrandSanderson", new Paging(lastTweetID));

        if (tweets != null) {
            long brandonID = 28187205;
            Hashtable<Long, DB.Tweet> findTweet = new Hashtable<>(tweets.size() * 16, 0.25f);
            List<DB.Tweet> dbTweets = new ArrayList<>(tweets.size());
            for (twitter4j.Status tweet : tweets) {
                // Create the tweet
                if (tweet.isRetweet())
                    tweet = tweet.getRetweetedStatus();

                long tweetID = tweet.getId();
                // TODO: Include the tweets in the DB
                if (findTweet.get(tweetID) == null)// This eliminate tweets already in the replies tree
                {
                    DB.Tweet dbTweet = new DB.Tweet(tweetID, getTweetText(tweet), tweet.getCreatedAt(), false,
                            tweet.getUser().getName(), tweet.getUser().getBiggerProfileImageURLHttps());
                    InternetHelper.getRemoteFile(tweet.getUser().getBiggerProfileImageURLHttps());
                    dbTweets.add(dbTweet);
                    findTweet.put(tweetID, dbTweet);

                    // Traverse the tree of the replies tweets
                    twitter4j.Status treeTweet = tweet;
                    while (treeTweet != null && treeTweet.getInReplyToStatusId() >= 0) {
                        try {
                            long id = treeTweet.getInReplyToStatusId();
                            long userID = treeTweet.getUser().getId();
                            treeTweet = null;
                            if (findTweet.get(id) == null || brandonID == userID)
                                treeTweet = twitter.showStatus(id);
                            else// Remove duplicates. Not sure why they appear, but the difference of the text is a dot at the end.
                                dbTweets.remove(dbTweets.size() - 1);
                        } catch (Exception ignore) {
                        }

                        if (treeTweet != null) {
                            findTweet.put(treeTweet.getId(), dbTweet);
                            StringBuilder replyBuilder = new StringBuilder();

                            replyBuilder.append("<blockquote>");

                            // Profile image
                            replyBuilder.append("<img src=\"");
                            InternetHelper.getRemoteFile(treeTweet.getUser().getBiggerProfileImageURLHttps());
                            replyBuilder.append(treeTweet.getUser().getBiggerProfileImageURLHttps());
                            replyBuilder.append("\"/>&nbsp;<b>");

                            // Username - date
                            replyBuilder.append(treeTweet.getUser().getName());
                            replyBuilder.append("</b> @");
                            replyBuilder.append(treeTweet.getUser().getScreenName());
                            replyBuilder.append(" - ");
                            replyBuilder
                                    .append(TwitterFragment.showDateFormat.format(treeTweet.getCreatedAt()));

                            // Tweet text
                            replyBuilder.append("<br/>");
                            replyBuilder.append(getTweetText(treeTweet));

                            // Remaining
                            replyBuilder.append(dbTweet.htmlReply);
                            replyBuilder.append("</blockquote>");

                            dbTweet.htmlReply = replyBuilder.toString();
                        }
                    }
                }
            }
            DB.Tweet.updateTwitter(dbTweets);
        }
    } catch (Exception e) {
        Logger.reportError(e.toString());
        state = DownloadParseSaveTask.STATE_ERROR_PARSING;
    }

    return state;
}

From source file:com.daiv.android.twitter.adapters.TimelineArrayAdapter.java

License:Apache License

public void getFavoriteCount(final ViewHolder holder, final long tweetId) {

    Thread getCount = new Thread(new Runnable() {
        @Override/*from   www .j a v  a 2  s.c  o  m*/
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, settings);
                final Status status;
                if (holder.retweeter.getVisibility() != View.GONE) {
                    status = twitter.showStatus(holder.tweetId).getRetweetedStatus();
                } else {
                    status = twitter.showStatus(tweetId);
                }

                if (status != null && holder.tweetId == tweetId) {
                    ((Activity) context).runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            holder.favCount.setText(" " + status.getFavoriteCount());

                            if (status.isFavorited()) {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                if (!settings.addonTheme) {
                                    holder.favorite
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    holder.favorite.setColorFilter(settings.accentInt);
                                }

                                holder.favorite.setImageDrawable(context.getResources().getDrawable(resource));
                                holder.isFavorited = true;
                            } else {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.notFavoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                holder.favorite.setImageDrawable(context.getResources().getDrawable(resource));
                                holder.isFavorited = false;

                                holder.favorite.clearColorFilter();
                            }
                        }
                    });
                }

            } catch (Exception e) {

            }
        }
    });

    getCount.setPriority(7);
    getCount.start();
}

From source file:com.daiv.android.twitter.adapters.TimelineArrayAdapter.java

License:Apache License

public void getCounts(final ViewHolder holder, final long tweetId) {

    Thread getCount = new Thread(new Runnable() {
        @Override/*from w w w . j a va2  s.c o  m*/
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, settings);
                final Status status;

                status = twitter.showStatus(tweetId);

                if (status != null) {
                    ((Activity) context).runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            holder.favCount.setText(" " + status.getFavoriteCount());
                            holder.retweetCount.setText(" " + status.getRetweetCount());

                            if (status.isFavorited()) {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                if (!settings.addonTheme) {
                                    holder.favorite
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    holder.favorite.setColorFilter(settings.accentInt);
                                }

                                holder.favorite.setImageDrawable(context.getResources().getDrawable(resource));
                                holder.isFavorited = true;
                            } else {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.notFavoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                holder.favorite.setImageDrawable(context.getResources().getDrawable(resource));
                                holder.isFavorited = false;

                                holder.favorite.clearColorFilter();
                            }

                            if (status.isRetweetedByMe()) {
                                if (!settings.addonTheme) {
                                    holder.retweet
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    holder.retweet.setColorFilter(settings.accentInt);
                                }
                            } else {
                                holder.retweet.clearColorFilter();
                            }
                        }
                    });
                }

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

    getCount.setPriority(7);
    getCount.start();
}

From source file:com.daiv.android.twitter.adapters.TimelineArrayAdapter.java

License:Apache License

public void getRetweetCount(final ViewHolder holder, final long tweetId) {

    Thread getRetweetCount = new Thread(new Runnable() {
        @Override//  ww  w  .  j  a  va2 s  .  c  o m
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, settings);
                twitter4j.Status status = twitter.showStatus(holder.tweetId);
                final boolean retweetedByMe = status.isRetweetedByMe();
                final String count = "" + status.getRetweetCount();
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if (tweetId == holder.tweetId) {
                            if (retweetedByMe) {
                                if (!settings.addonTheme) {
                                    holder.retweet
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    holder.retweet.setColorFilter(settings.accentInt);
                                }
                            } else {
                                holder.retweet.clearColorFilter();
                            }
                            if (count != null) {
                                holder.retweetCount.setText(" " + count);
                            }
                        }
                    }
                });

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

    getRetweetCount.setPriority(7);
    getRetweetCount.start();
}

From source file:com.daiv.android.twitter.ui.search.TwitterSearchFragment.java

License:Apache License

public void findStatus(final long statusid) {
    listView.setVisibility(View.GONE);
    spinner.setVisibility(View.VISIBLE);
    hasMore = false;//from   w  ww .  j  a  va2 s  . c o  m

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

                final ArrayList<Status> statuses = new ArrayList<Status>();

                statuses.add(status);

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

                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        spinner.setVisibility(View.GONE);
                    }
                });
                hasMore = false;
            }
        }
    }).start();
}

From source file:com.daiv.android.twitter.ui.tweet_viewer.fragments.TweetFragment.java

License:Apache License

public void getFavoriteCount(final TextView favs, final View favButton, final long tweetId) {
    new Thread(new Runnable() {
        @Override//from  www  . jav  a2 s.  c o m
        public void run() {
            try {
                Twitter twitter = getTwitter();
                twitter4j.Status status = twitter.showStatus(tweetId);
                if (status.isRetweet()) {
                    twitter4j.Status retweeted = status.getRetweetedStatus();
                    status = retweeted;
                }

                final twitter4j.Status fStatus = status;
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        favs.setText(" " + fStatus.getFavoriteCount());

                        if (fStatus.isFavorited()) {
                            TypedArray a = context.getTheme()
                                    .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                            int resource = a.getResourceId(0, 0);
                            a.recycle();

                            if (favButton instanceof ImageButton) {
                                if (!settings.addonTheme) {
                                    ((ImageButton) favButton)
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    ((ImageButton) favButton).setColorFilter(settings.accentInt);
                                }

                                ((ImageButton) favButton)
                                        .setImageDrawable(context.getResources().getDrawable(resource));
                            } else if (favButton instanceof LinearLayout) {
                                if (!settings.addonTheme) {
                                    favButton.setBackgroundColor(
                                            context.getResources().getColor(R.color.app_color));
                                } else {
                                    favButton.setBackgroundColor(settings.accentInt);
                                }
                            }
                            isFavorited = true;
                        } else {
                            TypedArray a = context.getTheme()
                                    .obtainStyledAttributes(new int[] { R.attr.notFavoritedButton });
                            int resource = a.getResourceId(0, 0);
                            a.recycle();

                            if (favButton instanceof ImageButton) {
                                ((ImageButton) favButton)
                                        .setImageDrawable(context.getResources().getDrawable(resource));
                                isFavorited = false;

                                ((ImageButton) favButton).clearColorFilter();
                            } else {
                                favButton.setBackgroundColor(
                                        getResources().getColor(android.R.color.transparent));
                            }
                        }
                    }
                });
            } catch (Exception e) {

            }
        }
    }).start();
}

From source file:com.daiv.android.twitter.ui.tweet_viewer.fragments.TweetFragment.java

License:Apache License

public void getInfo(final View favButton, final TextView favCount, final TextView retweetCount,
        final long tweetId, final View retweetButton) {

    Thread getInfo = new Thread(new Runnable() {
        @Override//from  ww  w .  j a v a 2  s. co  m
        public void run() {
            String location = "";
            String via = "";
            long realTime = 0;
            boolean retweetedByMe = false;
            try {
                Twitter twitter = getTwitter();

                TwitterMultipleImageHelper helper = new TwitterMultipleImageHelper();
                status = twitter.showStatus(tweetId);

                ArrayList<String> i = new ArrayList<String>();

                if (picture) {
                    i = helper.getImageURLs(status, twitter);
                }

                final ArrayList<String> images = i;

                GeoLocation loc = status.getGeoLocation();
                try {
                    Geocoder geocoder = new Geocoder(context, Locale.getDefault());
                    List<Address> addresses = geocoder.getFromLocation(loc.getLatitude(), loc.getLongitude(),
                            1);
                    if (addresses.size() > 0) {
                        Address address = addresses.get(0);
                        location += address.getLocality() + ", " + address.getCountryName();
                    } else {
                        location = "";
                    }
                } catch (Exception x) {
                    location = "";
                }

                via = android.text.Html.fromHtml(status.getSource()).toString();

                final String sfavCount;
                if (status.isRetweet()) {
                    twitter4j.Status status2 = status.getRetweetedStatus();
                    via = android.text.Html.fromHtml(status2.getSource()).toString();
                    realTime = status2.getCreatedAt().getTime();
                    sfavCount = status2.getFavoriteCount() + "";
                } else {
                    realTime = status.getCreatedAt().getTime();
                    sfavCount = status.getFavoriteCount() + "";
                }

                retweetedByMe = status.isRetweetedByMe();
                final String retCount = "" + status.getRetweetCount();

                final String timeDisplay;

                if (!settings.militaryTime) {
                    timeDisplay = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).format(realTime)
                            + " " + DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US).format(realTime);
                } else {
                    timeDisplay = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.GERMAN).format(realTime)
                            + " "
                            + DateFormat.getTimeInstance(DateFormat.SHORT, Locale.GERMAN).format(realTime);
                }
                final String fVia = " " + getResources().getString(R.string.via) + " " + via;
                final String fLoc = location.equals("") ? "" : "\n" + location;

                final boolean fRet = retweetedByMe;
                final long fTime = realTime;
                final Status fStatus = status;
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {

                        // you can't retweet a protected account
                        if (status.getUser().isProtected()) {
                            retweetButton.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    Toast.makeText(context, getString(R.string.protected_account),
                                            Toast.LENGTH_SHORT).show();
                                }
                            });
                        }

                        retweetCount.setText(" " + retCount);

                        if (retweetButton instanceof ImageButton) {
                            if (fRet) {
                                if (!settings.addonTheme) {
                                    ((ImageButton) retweetButton)
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    ((ImageButton) retweetButton).setColorFilter(settings.accentInt);
                                }
                            } else {
                                ((ImageButton) retweetButton).clearColorFilter();
                            }
                        } else {
                            if (fRet) {
                                if (!settings.addonTheme) {
                                    retweetButton.setBackgroundColor(
                                            context.getResources().getColor(R.color.app_color));
                                } else {
                                    retweetButton.setBackgroundColor(settings.accentInt);
                                }
                            } else {
                                retweetButton.setBackgroundColor(
                                        getResources().getColor(android.R.color.transparent));
                            }
                        }

                        timetv.setText(timeDisplay + fVia);
                        timetv.append(fLoc);

                        favCount.setText(" " + sfavCount);

                        if (favButton instanceof ImageButton) {
                            if (fStatus.isFavorited()) {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                if (!settings.addonTheme) {
                                    ((ImageButton) favButton)
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    ((ImageButton) favButton).setColorFilter(settings.accentInt);
                                }

                                ((ImageButton) favButton)
                                        .setImageDrawable(context.getResources().getDrawable(resource));
                                isFavorited = true;
                            } else {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.notFavoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                ((ImageButton) favButton)
                                        .setImageDrawable(context.getResources().getDrawable(resource));
                                isFavorited = false;

                                ((ImageButton) favButton).clearColorFilter();
                            }
                        } else {
                            if (fStatus.isFavorited()) {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                if (!settings.addonTheme) {
                                    favButton.setBackgroundColor(
                                            context.getResources().getColor(R.color.app_color));
                                } else {
                                    favButton.setBackgroundColor(settings.accentInt);
                                }

                                isFavorited = true;
                            } else {
                                isFavorited = false;

                                favButton.setBackgroundColor(
                                        getResources().getColor(android.R.color.transparent));
                            }
                        }

                        for (String s : images) {
                            Log.v("Test_image", s);
                        }
                    }
                });
            } catch (Exception e) {

            }
        }
    });

    getInfo.setPriority(Thread.MAX_PRIORITY);
    getInfo.start();
}

From source file:com.daiv.android.twitter.ui.tweet_viewer.fragments.TweetFragment.java

License:Apache License

public void getRetweetCount(final TextView retweetCount, final long tweetId, final View retweetButton) {

    new Thread(new Runnable() {
        @Override//  w  ww .j a v  a  2s.  c  o m
        public void run() {
            boolean retweetedByMe;
            try {
                Twitter twitter = getTwitter();
                twitter4j.Status status = twitter.showStatus(tweetId);

                retweetedByMe = status.isRetweetedByMe();
                final String retCount = "" + status.getRetweetCount();

                final boolean fRet = retweetedByMe;
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {

                        try {
                            retweetCount.setText(" " + retCount);

                            if (retweetButton instanceof ImageButton) {
                                if (fRet) {
                                    if (!settings.addonTheme) {
                                        ((ImageButton) retweetButton).setColorFilter(
                                                context.getResources().getColor(R.color.app_color));
                                    } else {
                                        ((ImageButton) retweetButton).setColorFilter(settings.accentInt);
                                    }
                                } else {
                                    ((ImageButton) retweetButton).clearColorFilter();
                                }
                            } else {
                                if (fRet) {
                                    if (!settings.addonTheme) {
                                        retweetButton.setBackgroundColor(
                                                context.getResources().getColor(R.color.app_color));
                                    } else {
                                        retweetButton.setBackgroundColor(settings.accentInt);
                                    }
                                } else {
                                    retweetButton.setBackgroundColor(
                                            getResources().getColor(android.R.color.transparent));
                                }
                            }
                        } catch (Exception x) {
                            // not attached to activity
                        }
                    }
                });
            } catch (Exception e) {

            }
        }
    }).start();
}