List of usage examples for twitter4j Status getRetweetedStatus
Status getRetweetedStatus();
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 w ww . j av a 2s. co 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.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 .ja v a 2 s.c o 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 ava 2 s .c o m } 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.StatusCacheRealm.java
License:Apache License
@NonNull private Collection<Status> splitUpsertingStatus(Collection<Status> statuses) { final LinkedHashMap<Long, Status> updates = new LinkedHashMap<>(); for (Status s : statuses) { if (!configStore.isIgnoredUser(s.getUser().getId())) { updates.put(s.getId(), s);/*from w w w . j a v a 2 s. co m*/ } final Status quotedStatus = s.getQuotedStatus(); if (quotedStatus != null && !configStore.isIgnoredUser(quotedStatus.getUser().getId())) { updates.put(quotedStatus.getId(), quotedStatus); } final Status retweetedStatus = s.getRetweetedStatus(); if (retweetedStatus != null && !configStore.isIgnoredUser(retweetedStatus.getUser().getId())) { updates.put(retweetedStatus.getId(), retweetedStatus); final Status rtQuotedStatus = retweetedStatus.getQuotedStatus(); if (rtQuotedStatus != null && !configStore.isIgnoredUser(rtQuotedStatus.getUser().getId())) { updates.put(rtQuotedStatus.getId(), rtQuotedStatus); } } } return updates.values(); }
From source file:com.freshdigitable.udonroad.module.realm.StatusIDs.java
License:Apache License
StatusIDs(Status status) { this.id = status.getId(); final Status retweetedStatus = status.getRetweetedStatus(); this.retweetedStatusId = retweetedStatus != null ? retweetedStatus.getId() : -1; this.quotedStatusId = status.getQuotedStatusId(); }
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 va2 s . com*/ 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.TimelineStoreRealm.java
License:Apache License
private boolean isIgnorable(Status status) { return configStore.isIgnoredUser(status.getUser().getId()) || (status.isRetweet() && configStore.isIgnoredUser(status.getRetweetedStatus().getUser().getId())); }
From source file:com.freshdigitable.udonroad.module.realm.TimelineStoreRealm.java
License:Apache License
private List<StatusIDs> createUpdateList(List<Status> statuses) { if (!updateEvent.hasObservers()) { return Collections.emptyList(); }/*from w w w . jav a 2 s . c o m*/ final List<StatusIDs> updates = new ArrayList<>(); for (Status s : statuses) { final StatusIDs update = findTimeline(s); if (update != null) { updates.add(update); } final RealmResults<StatusIDs> u = findReferringStatus(s.getId()); if (!u.isEmpty()) { updates.addAll(u); } final long quotedStatusId = s.getQuotedStatusId(); if (quotedStatusId > 0) { final Status quotedStatus = s.getQuotedStatus(); final StatusIDs q = findTimeline(quotedStatus); if (q != null) { updates.add(q); } final RealmResults<StatusIDs> updatedQuotedStatus = findReferringStatus(quotedStatusId); if (!updatedQuotedStatus.isEmpty()) { updates.addAll(updatedQuotedStatus); } } if (!s.isRetweet()) { continue; } final Status retweetedStatus = s.getRetweetedStatus(); final StatusIDs rs = findTimeline(retweetedStatus); if (rs != null) { updates.add(rs); } final RealmResults<StatusIDs> rtedUpdate = findReferringStatus(retweetedStatus.getId()); if (!rtedUpdate.isEmpty()) { updates.addAll(rtedUpdate); } final long rtQuotedStatusId = retweetedStatus.getQuotedStatusId(); if (rtQuotedStatusId > 0) { final RealmResults<StatusIDs> rtUpdatedQuotedStatus = findReferringStatus(rtQuotedStatusId); if (!rtUpdatedQuotedStatus.isEmpty()) { updates.addAll(rtUpdatedQuotedStatus); } } } return updates; }
From source file:com.freshdigitable.udonroad.StatusViewBase.java
License:Apache License
protected Status getBindingStatus(Status status) { return status.isRetweet() ? status.getRetweetedStatus() : status; }
From source file:com.freshdigitable.udonroad.StatusViewImageHelper.java
License:Apache License
public static Status getBindingStatus(Status status) { return status.isRetweet() ? status.getRetweetedStatus() : status; }