Example usage for twitter4j Status getRetweetCount

List of usage examples for twitter4j Status getRetweetCount

Introduction

In this page you can find the example usage for twitter4j Status getRetweetCount.

Prototype

int getRetweetCount();

Source Link

Document

Returns the number of times this tweet has been retweeted, or -1 when the tweet was created before this feature was enabled.

Usage

From source file:com.daemon.database.Transactor.java

License:Open Source License

/**
 * Adds the relation between the given tweet and the search term-id (DB
 * specific) the tweet was found with to the SQL Batched executed by 
 * the saveAllTransactionSafe Function//from  w  w  w . jav  a2s.c o  m
 * 
 * @param tweet  The tweet related to the search term-id.
 * @param term   The search term related to the tweet.
 * @throws SQLException
 */
private void saveTweetWithTerm(Status tweet, SearchTerm term, RegressionSentimentClassifier sentimentClassifier)
        throws SQLException {
    try {
        prepStatementTweetWithTerm.setLong(1, tweet.getId()); // tweet_id
        prepStatementTweetWithTerm.setInt(2, term.getId()); // search_term_id
        prepStatementTweetWithTerm.setString(3, tweet.getIsoLanguageCode()); // iso__language_code
        // sentiment
        Float sentiment = sentimentClassifier.determineSentiment(tweet.getText(), tweet.getIsoLanguageCode());
        if (sentiment == null) {
            prepStatementTweetWithTerm.setNull(4, java.sql.Types.NULL);
        } else {
            prepStatementTweetWithTerm.setFloat(4,
                    sentimentClassifier.determineSentiment(tweet.getText(), tweet.getIsoLanguageCode()));
        }

        // created_at
        java.sql.Timestamp sqlTimestamp = new java.sql.Timestamp(tweet.getCreatedAt().getTime());
        prepStatementTweetWithTerm.setTimestamp(5, sqlTimestamp);
        // is_retweet_of_id
        if (tweet.getRetweetedStatus() != null) {
            prepStatementTweetWithTerm.setLong(6, tweet.getRetweetedStatus().getId());
        } else {
            prepStatementTweetWithTerm.setNull(6, java.sql.Types.NULL);
        }
        // retweet_count
        prepStatementTweetWithTerm.setInt(7, tweet.getRetweetCount());

        prepStatementTweetWithTerm.addBatch();
    } catch (Exception e) {
        // Doesn't make sense. we wouldn't find the tweet for the
        // search term if the search term was not in the database
        throw new SQLException(
                "Cannot save tweet with search term. The term has no Id (it was not inserted, yet).");
    }
}

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

License:Apache License

public void bindView(final View view, Status status, int position) {
    final ViewHolder holder = (ViewHolder) view.getTag();

    if (holder.expandArea.getVisibility() == View.VISIBLE) {
        removeExpansionNoAnimation(holder);
    }/*  w  ww .  java2 s  .c  o m*/

    Status thisStatus;

    String retweeter;
    final long time = status.getCreatedAt().getTime();
    long originalTime = 0;

    if (status.isRetweet()) {
        retweeter = status.getUser().getScreenName();

        thisStatus = status.getRetweetedStatus();
        originalTime = thisStatus.getCreatedAt().getTime();
    } else {
        retweeter = "";

        thisStatus = status;
    }

    final long fOriginalTime = originalTime;

    User user = thisStatus.getUser();

    holder.tweetId = thisStatus.getId();
    final long id = holder.tweetId;
    final String profilePic = user.getOriginalProfileImageURL();
    String tweetTexts = thisStatus.getText();
    final String name = user.getName();
    final String screenname = user.getScreenName();

    String[] html = TweetLinkUtils.getLinksInStatus(thisStatus);

    final String tweetText = html[0];
    final String picUrl = html[1];
    holder.picUrl = picUrl;
    final String otherUrl = html[2];
    final String hashtags = html[3];
    final String users = html[4];

    final boolean inAConversation = thisStatus.getInReplyToStatusId() != -1;

    holder.gifUrl = TweetLinkUtils.getGIFUrl(status, otherUrl);

    if (holder.isAConversation != null) {
        if (inAConversation) {
            if (holder.isAConversation.getVisibility() != View.VISIBLE) {
                holder.isAConversation.setVisibility(View.VISIBLE);
            }
        } else {
            if (holder.isAConversation.getVisibility() != View.GONE) {
                holder.isAConversation.setVisibility(View.GONE);
            }
        }
    }

    if (!settings.reverseClickActions) {
        final String fRetweeter = retweeter;
        holder.background.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {

                String link;

                boolean hasGif = holder.gifUrl != null && !holder.gifUrl.isEmpty();
                boolean displayPic = !holder.picUrl.equals("") && !holder.picUrl.contains("youtube")
                        && !(hasGif);
                if (displayPic) {
                    link = holder.picUrl;
                } else {
                    link = otherUrl.split("  ")[0];
                }

                Log.v("tweet_page", "clicked");

                return true;
            }
        });

        holder.background.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (holder.preventNextClick) {
                    holder.preventNextClick = false;
                    return;
                }
                if (holder.expandArea.getVisibility() == View.GONE) {
                    addExpansion(holder, screenname, users, otherUrl.split("  "), holder.picUrl, id);
                } else {
                    removeExpansionWithAnimation(holder);
                    removeKeyboard(holder);
                }
            }
        });

    } else {
        final String fRetweeter = retweeter;
        holder.background.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (holder.preventNextClick) {
                    holder.preventNextClick = false;
                    return;
                }

                String link;

                boolean hasGif = holder.gifUrl != null && !holder.gifUrl.isEmpty();
                boolean displayPic = !holder.picUrl.equals("") && !holder.picUrl.contains("youtube")
                        && !(hasGif);
                if (displayPic) {
                    link = holder.picUrl;
                } else {
                    link = otherUrl.split("  ")[0];
                }

                Log.v("tweet_page", "clicked");
            }
        });

        holder.background.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                if (holder.expandArea.getVisibility() == View.GONE) {
                    addExpansion(holder, screenname, users, otherUrl.split("  "), holder.picUrl, id);
                } else {
                    removeExpansionWithAnimation(holder);
                    removeKeyboard(holder);
                }

                return true;
            }
        });
    }

    if (!screenname.equals(username)) {

    } else {
        // need to clear the click listener so it isn't left over from another profile
        holder.profilePic.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });

        holder.profilePic.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View view) {
                return true;
            }
        });
    }

    if (TestLayout == AppSettings.LAYOUT_FULL_SCREEN
            || (settings.nameAndHandleOnTweet && settings.addonTheme)) {
        if (holder.screenTV.getVisibility() == View.GONE) {
            holder.screenTV.setVisibility(View.VISIBLE);
        }
        holder.screenTV.setText("@" + screenname);
        holder.name.setText(name);
    } else {
        if (!settings.showBoth) {
            holder.name.setText(settings.displayScreenName ? "@" + screenname : name);
        } else {
            if (holder.screenTV.getVisibility() == View.GONE) {
                holder.screenTV.setVisibility(View.VISIBLE);
            }
            holder.name.setText(name);
            holder.screenTV.setText("@" + screenname);
        }
    }

    if (!settings.absoluteDate) {
        holder.time.setText(Utils.getTimeAgo(time, context));
    } else {
        Date date = new Date(time);
        holder.time
                .setText(timeFormatter.format(date).replace("24:", "00:") + ", " + dateFormatter.format(date));
    }

    holder.tweet.setText(tweetText);

    boolean picture = false;

    if (settings.inlinePics) {
        if (holder.picUrl.equals("")) {
            if (holder.image.getVisibility() != View.GONE) {
                holder.image.setVisibility(View.GONE);
            }

            if (holder.playButton.getVisibility() == View.VISIBLE) {
                holder.playButton.setVisibility(View.GONE);
            }
        } else {
            if (holder.picUrl.contains("youtube")
                    || (holder.gifUrl != null && !android.text.TextUtils.isEmpty(holder.gifUrl))) {

                if (holder.playButton.getVisibility() == View.GONE) {
                    holder.playButton.setVisibility(View.VISIBLE);
                }

                final String fRetweeter = retweeter;

                holder.image.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        String link;

                        boolean hasGif = holder.gifUrl != null && !holder.gifUrl.isEmpty();
                        boolean displayPic = !holder.picUrl.equals("") && !holder.picUrl.contains("youtube")
                                && !(hasGif);
                        if (displayPic) {
                            link = holder.picUrl;
                        } else {
                            link = otherUrl.split("  ")[0];
                        }
                    }
                });

                holder.image.setImageDrawable(transparent);

                picture = true;

            } else {
                holder.image.setImageDrawable(transparent);

                picture = true;

                if (holder.playButton.getVisibility() == View.VISIBLE) {
                    holder.playButton.setVisibility(View.GONE);
                }
            }

            if (holder.image.getVisibility() == View.GONE) {
                holder.image.setVisibility(View.VISIBLE);
            }
        }
    }

    if (type == NORMAL) {
        if (retweeter.length() > 0) {
            holder.retweeter.setText(context.getResources().getString(R.string.retweeter) + retweeter);
            holder.retweeterName = retweeter;
            holder.retweeter.setVisibility(View.VISIBLE);
        } else if (holder.retweeter.getVisibility() == View.VISIBLE) {
            holder.retweeter.setVisibility(View.GONE);
        }
    } else if (type == RETWEET) {

        int count = status.getRetweetCount();

        if (count > 1) {
            holder.retweeter.setText(
                    status.getRetweetCount() + " " + context.getResources().getString(R.string.retweets_lower));
            holder.retweeter.setVisibility(View.VISIBLE);
        } else if (count == 1) {
            holder.retweeter.setText(
                    status.getRetweetCount() + " " + context.getResources().getString(R.string.retweet_lower));
            holder.retweeter.setVisibility(View.VISIBLE);
        }
    }

    if (picture) {
        CacheableBitmapDrawable wrapper = mCache.getFromMemoryCache(holder.picUrl);
        if (wrapper != null) {
            holder.image.setImageDrawable(wrapper);
            picture = false;
        }
    }

    final boolean hasPicture = picture;
    mHandler[currHandler].removeCallbacksAndMessages(null);
    mHandler[currHandler].postDelayed(new Runnable() {
        @Override
        public void run() {
            if (holder.tweetId == id) {
                if (hasPicture) {
                    loadImage(context, holder, holder.picUrl, mCache, id);
                }

                if (settings.useEmoji
                        && (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT || EmojiUtils.ios)) {
                    String text = holder.tweet.getText().toString();
                    if (EmojiUtils.emojiPattern.matcher(text).find()) {
                        final Spannable span = EmojiUtils.getSmiledText(context, Html.fromHtml(tweetText));
                        holder.tweet.setText(span);
                    }
                }

                holder.tweet.setSoundEffectsEnabled(false);
                holder.tweet.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if (!TouchableMovementMethod.touched) {
                            // we need to manually set the background for click feedback because the spannable
                            // absorbs the click on the background
                            if (!holder.preventNextClick) {
                                holder.background.getBackground()
                                        .setState(new int[] { android.R.attr.state_pressed });
                                new Handler().postDelayed(new Runnable() {
                                    @Override
                                    public void run() {
                                        holder.background.getBackground()
                                                .setState(new int[] { android.R.attr.state_empty });
                                    }
                                }, 25);
                            }

                            holder.background.performClick();
                        }
                    }
                });

                holder.tweet.setOnLongClickListener(new View.OnLongClickListener() {
                    @Override
                    public boolean onLongClick(View view) {
                        if (!TouchableMovementMethod.touched) {
                            holder.background.performLongClick();
                            holder.preventNextClick = true;
                        }
                        return false;
                    }
                });

                if (holder.retweeter.getVisibility() == View.VISIBLE) {
                    holder.retweeter.setSoundEffectsEnabled(false);
                    holder.retweeter.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            if (!TouchableMovementMethod.touched) {
                                if (!holder.preventNextClick) {
                                    holder.background.getBackground()
                                            .setState(new int[] { android.R.attr.state_pressed });
                                    new Handler().postDelayed(new Runnable() {
                                        @Override
                                        public void run() {
                                            holder.background.getBackground()
                                                    .setState(new int[] { android.R.attr.state_empty });
                                        }
                                    }, 25);
                                }

                                holder.background.performClick();
                            }
                        }
                    });

                    holder.retweeter.setOnLongClickListener(new View.OnLongClickListener() {
                        @Override
                        public boolean onLongClick(View view) {
                            if (!TouchableMovementMethod.touched) {
                                holder.background.performLongClick();
                                holder.preventNextClick = true;
                            }
                            return false;
                        }
                    });
                }

                TextUtils.linkifyText(context, holder.tweet, holder.background, true, otherUrl, false);
                TextUtils.linkifyText(context, holder.retweeter, holder.background, true, "", false);
            }
        }
    }, 400);
    currHandler++;

    if (currHandler == 10) {
        currHandler = 0;
    }

    if (openFirst && position == 0) {
        holder.background.performClick();
    }
}

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/*  w  ww .ja  va 2s.com*/
        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//from w w  w  .  j ava2  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.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/*from  w  w  w .  j a  v  a 2 s  .  co 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();
}

From source file:com.dwdesign.tweetings.model.ParcelableStatus.java

License:Open Source License

public ParcelableStatus(Status status, final long account_id, final boolean is_gap,
        final boolean large_inline_image_preview) {

    this.is_gap = is_gap;
    this.account_id = account_id;
    status_id = status.getId();/*from  www  .j a v a  2s  .  co  m*/
    is_retweet = status.isRetweet();
    final Status retweeted_status = is_retweet ? status.getRetweetedStatus() : null;
    final User retweet_user = retweeted_status != null ? status.getUser() : null;
    retweet_id = retweeted_status != null ? retweeted_status.getId() : -1;
    retweeted_by_id = retweet_user != null ? retweet_user.getId() : -1;
    retweeted_by_name = retweet_user != null ? retweet_user.getName() : null;
    retweeted_by_screen_name = retweet_user != null ? retweet_user.getScreenName() : null;
    if (retweeted_status != null) {
        status = retweeted_status;
    }
    final User user = status.getUser();
    user_id = user != null ? user.getId() : -1;
    name = user != null ? user.getName() : null;
    screen_name = user != null ? user.getScreenName() : null;
    profile_image_url = user != null ? user.getProfileImageURL() : null;
    profile_image_url_string = profile_image_url != null ? profile_image_url.toString() : null;
    is_protected = user != null ? user.isProtected() : false;
    is_verified = user != null ? user.isVerified() : false;
    final MediaEntity[] medias = status.getMediaEntities();

    status_timestamp = getTime(status.getCreatedAt());
    text_html = formatStatusText(status);
    final PreviewImage preview = getPreviewImage(text_html,
            large_inline_image_preview ? INLINE_IMAGE_PREVIEW_DISPLAY_OPTION_CODE_LARGE_HIGH
                    : INLINE_IMAGE_PREVIEW_DISPLAY_OPTION_CODE_SMALL);
    text_plain = status.getText();
    retweet_count = status.getRetweetCount();
    in_reply_to_screen_name = status.getInReplyToScreenName();
    in_reply_to_status_id = status.getInReplyToStatusId();
    source = status.getSource();
    location = new ParcelableLocation(status.getGeoLocation());
    location_string = location.toString();
    is_favorite = status.isFavorited();
    has_media = medias != null && medias.length > 0 || preview.has_image;
    text = text_html != null ? Html.fromHtml(text_html) : null;
    image_preview_url_string = preview.matched_url;
    image_orig_url_string = preview.orig_url;
    image_preview_url = parseURL(image_preview_url_string);
    text_unescaped = unescape(text_html);
    String play = null;
    URLEntity[] urls = status.getURLEntities();
    if (urls != null) {
        for (final URLEntity url : urls) {
            final URL tco_url = url.getURL();
            final URL expanded_url = url.getExpandedURL();
            if (tco_url != null && expanded_url != null
                    && expanded_url.toString().contains("play.google.com/store/apps")) {
                play = expanded_url.toString();
                break;
            }

        }
    }
    play_package = play;
    is_possibly_sensitive = status.isPossiblySensitive();
}

From source file:com.dwdesign.tweetings.util.Utils.java

License:Open Source License

public static ContentValues makeStatusContentValues(Status status, final long account_id) {
    if (status == null || status.getId() <= 0)
        return null;
    final ContentValues values = new ContentValues();
    values.put(Statuses.ACCOUNT_ID, account_id);
    values.put(Statuses.STATUS_ID, status.getId());
    final boolean is_retweet = status.isRetweet();
    final Status retweeted_status = is_retweet ? status.getRetweetedStatus() : null;
    if (retweeted_status != null) {
        final User retweet_user = status.getUser();
        values.put(Statuses.RETWEET_ID, retweeted_status.getId());
        values.put(Statuses.RETWEETED_BY_ID, retweet_user.getId());
        values.put(Statuses.RETWEETED_BY_NAME, retweet_user.getName());
        values.put(Statuses.RETWEETED_BY_SCREEN_NAME, retweet_user.getScreenName());
        status = retweeted_status;// w w  w  .j av a2s  .  c  om
    }
    final User user = status.getUser();
    if (user != null) {
        final long user_id = user.getId();
        final String profile_image_url = user.getProfileImageURL().toString();
        final String name = user.getName(), screen_name = user.getScreenName();
        values.put(Statuses.USER_ID, user_id);
        values.put(Statuses.NAME, name);
        values.put(Statuses.SCREEN_NAME, screen_name);
        values.put(Statuses.IS_PROTECTED, user.isProtected() ? 1 : 0);
        values.put(Statuses.IS_VERIFIED, user.isVerified() ? 1 : 0);
        values.put(Statuses.PROFILE_IMAGE_URL, profile_image_url);
    }
    if (status.getCreatedAt() != null) {
        values.put(Statuses.STATUS_TIMESTAMP, status.getCreatedAt().getTime());
    }
    values.put(Statuses.TEXT, formatStatusText(status));
    values.put(Statuses.TEXT_PLAIN, status.getText());
    values.put(Statuses.RETWEET_COUNT, status.getRetweetCount());
    values.put(Statuses.IN_REPLY_TO_SCREEN_NAME, status.getInReplyToScreenName());
    values.put(Statuses.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId());
    values.put(Statuses.SOURCE, status.getSource());
    values.put(Statuses.IS_POSSIBLY_SENSITIVE, status.isPossiblySensitive());
    final GeoLocation location = status.getGeoLocation();
    if (location != null) {
        values.put(Statuses.LOCATION, location.getLatitude() + "," + location.getLongitude());
    }
    values.put(Statuses.IS_RETWEET, is_retweet ? 1 : 0);
    values.put(Statuses.IS_FAVORITE, status.isFavorited() ? 1 : 0);
    return values;
}

From source file:com.freshdigitable.udonroad.module.realm.StatusRealm.java

License:Apache License

StatusRealm(Status status) {
    this.id = status.getId();
    this.createdAt = status.getCreatedAt();
    this.retweetedStatus = status.getRetweetedStatus();
    this.retweet = status.isRetweet();
    if (status.isRetweet()) {
        this.retweetedStatusId = this.retweetedStatus.getId();
    }//from   w ww  .j  a  v a  2 s . co m
    this.text = status.getText();
    this.source = status.getSource();
    this.retweetCount = status.getRetweetCount();
    this.favoriteCount = status.getFavoriteCount();
    this.reaction = new StatusReactionImpl(status);
    this.user = status.getUser();
    this.userId = user.getId();
    this.urlEntities = URLEntityRealm.createList(status.getURLEntities());

    this.mediaEntities = new RealmList<>();
    final ExtendedMediaEntity[] me = status.getExtendedMediaEntities();
    for (ExtendedMediaEntity m : me) {
        mediaEntities.add(new ExtendedMediaEntityRealm(m));
    }
    final UserMentionEntity[] userMentionEntities = status.getUserMentionEntities();
    this.userMentionEntities = new RealmList<>();
    for (UserMentionEntity u : userMentionEntities) {
        this.userMentionEntities.add(new UserMentionEntityRealm(u));
    }

    this.quotedStatus = status.getQuotedStatus();
    this.quotedStatusId = status.getQuotedStatusId();
}

From source file:com.freshdigitable.udonroad.module.realm.StatusRealm.java

License:Apache License

void merge(@NonNull Status s) {
    final int favoriteCount = s.getFavoriteCount();
    if (favoriteCount > 0 && favoriteCount != this.favoriteCount) { // favoriteCount is nullable
        this.favoriteCount = favoriteCount;
    }//from  w  w  w  .  ja  v  a2  s  .  c o  m
    final int retweetCount = s.getRetweetCount();
    if (retweetCount > 0 && retweetCount != this.retweetCount) { // retweetCount is nullable
        this.retweetCount = retweetCount;
    }
}

From source file:com.freshdigitable.udonroad.StatusViewBase.java

License:Apache License

protected void bindRT(Status bindingStatus) {
    final int rtCount = bindingStatus.getRetweetCount();
    if (rtCount > 0) {
        this.setRtCountVisibility(VISIBLE);
        setTint(rtIcon,/*from  ww  w .  j  a v  a 2  s  .  c  om*/
                bindingStatus.isRetweeted() ? R.color.twitter_action_retweeted : R.color.twitter_action_normal);
        this.rtCount.setText(String.valueOf(rtCount));
    }
}