List of usage examples for twitter4j Status isRetweetedByMe
boolean isRetweetedByMe();
From source file:au.net.moon.tUtils.twitterFields.java
License:Open Source License
/** * Get a <CODE>HashMap</CODE> of tweet fields by parsing a twitter4j Status * /*from w w w .ja v a 2 s . c o m*/ * @param status * the twitter4j Status object * @return the tweet fields as name, value pairs in a <CODE>HashMap</CODE>. */ public static HashMap<String, String> parseStatusObj(Status status) { HashMap<String, String> splitFields = new HashMap<String, String>(); splitFields.put("createdAt", status.getCreatedAt().toString()); splitFields.put("id", Long.toString(status.getId())); splitFields.put("text", status.getText()); splitFields.put("source", status.getSource()); splitFields.put("isTruncated", status.isTruncated() ? "1" : "0"); splitFields.put("inReplyToStatusId", Long.toString(status.getInReplyToStatusId())); splitFields.put("inReplyToUserId", Long.toString(status.getInReplyToUserId())); splitFields.put("isFavorited", status.isFavorited() ? "1" : "0"); splitFields.put("inReplyToScreenName", status.getInReplyToScreenName()); if (status.getGeoLocation() != null) { splitFields.put("geoLocation", status.getGeoLocation().toString()); } else { splitFields.put("geoLocation", ""); } if (status.getPlace() != null) { splitFields.put("place", status.getPlace().toString()); } else { splitFields.put("place", ""); } splitFields.put("retweetCount", Long.toString(status.getRetweetCount())); splitFields.put("wasRetweetedByMe", status.isRetweetedByMe() ? "1" : "0"); String contributors = ""; if (status.getContributors() != null) { long[] tempContributors = status.getContributors(); for (int i = 0; i < tempContributors.length; i++) { contributors += Long.toString(tempContributors[i]); if (i != tempContributors.length - 1) { contributors += ", "; } } } splitFields.put("contributors", contributors); splitFields.put("annotations", ""); if (status.getRetweetedStatus() != null) { splitFields.put("retweetedStatus", "1"); } else { splitFields.put("retweetedStatus", "0"); } splitFields.put("userMentionEntities", status.getUserMentionEntities().toString()); splitFields.put("urlEntities", status.getURLEntities().toString()); splitFields.put("hashtagEntities", status.getHashtagEntities().toString()); splitFields.put("user", status.getUser().toString()); return splitFields; }
From source file:cojoytuerto.CojoYTuertoFrame.java
private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked // TODO add your handling code here: if (evt.getClickCount() == 2) { Status ms = mensajes.get(jTable1.getSelectedRow()); DefaultTableModel tm = (DefaultTableModel) jTable1.getModel(); if (jTable1.getColumnName(jTable1.getSelectedColumn()).equals("FV")) { //FV//ww w .j a va 2s .com System.out.println("FV: " + ms.getText()); try { twitter.createFavorite(ms.getId()); } catch (TwitterException ex) { Logger.getLogger(CojoYTuertoFrame.class.getName()).log(Level.SEVERE, null, ex); } tm.setValueAt("FV", jTable1.getSelectedRow(), jTable1.getSelectedColumn()); } else if (jTable1.getColumnName(jTable1.getSelectedColumn()).equals("RT")) { //RT if (!ms.isRetweetedByMe()) { try { twitter.retweetStatus(ms.getId()); System.out.println("RT: " + mensajes.get(jTable1.getSelectedRow()).getText()); } catch (TwitterException ex) { Logger.getLogger(CojoYTuertoFrame.class.getName()).log(Level.SEVERE, null, ex); } } tm.setValueAt("RT", jTable1.getSelectedRow(), jTable1.getSelectedColumn()); } } }
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 ww w . 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/* w w w . ja va2 s . co 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 ww . j ava 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.github.jcustenborder.kafka.connect.twitter.StatusConverter.java
License:Apache License
public static void convert(Status status, Struct struct) { struct.put("CreatedAt", status.getCreatedAt()).put("Id", status.getId()).put("Text", status.getText()) .put("Source", status.getSource()).put("Truncated", status.isTruncated()) .put("InReplyToStatusId", status.getInReplyToStatusId()) .put("InReplyToUserId", status.getInReplyToUserId()) .put("InReplyToScreenName", status.getInReplyToScreenName()).put("Favorited", status.isFavorited()) .put("Retweeted", status.isRetweeted()).put("FavoriteCount", status.getFavoriteCount()) .put("Retweet", status.isRetweet()).put("RetweetCount", status.getRetweetCount()) .put("RetweetedByMe", status.isRetweetedByMe()) .put("CurrentUserRetweetId", status.getCurrentUserRetweetId()) .put("PossiblySensitive", status.isPossiblySensitive()).put("Lang", status.getLang()); Struct userStruct;/*from w ww .j a va 2 s .c o m*/ if (null != status.getUser()) { userStruct = new Struct(USER_SCHEMA); convert(status.getUser(), userStruct); } else { userStruct = null; } struct.put("User", userStruct); Struct placeStruct; if (null != status.getPlace()) { placeStruct = new Struct(PLACE_SCHEMA); convert(status.getPlace(), placeStruct); } else { placeStruct = null; } struct.put("Place", placeStruct); Struct geoLocationStruct; if (null != status.getGeoLocation()) { geoLocationStruct = new Struct(GEO_LOCATION_SCHEMA); convert(status.getGeoLocation(), geoLocationStruct); } else { geoLocationStruct = null; } struct.put("GeoLocation", geoLocationStruct); List<Long> contributers = new ArrayList<>(); if (null != status.getContributors()) { for (Long l : status.getContributors()) { contributers.add(l); } } struct.put("Contributors", contributers); List<String> withheldInCountries = new ArrayList<>(); if (null != status.getWithheldInCountries()) { for (String s : status.getWithheldInCountries()) { withheldInCountries.add(s); } } struct.put("WithheldInCountries", withheldInCountries); struct.put("HashtagEntities", convert(status.getHashtagEntities())); struct.put("UserMentionEntities", convert(status.getUserMentionEntities())); struct.put("MediaEntities", convert(status.getMediaEntities())); struct.put("SymbolEntities", convert(status.getSymbolEntities())); struct.put("URLEntities", convert(status.getURLEntities())); }
From source file:com.klinker.android.twitter.adapters.TimeLineCursorAdapter.java
License:Apache License
public void getCounts(final ViewHolder holder, final long tweetId) { Thread getCount = new Thread(new Runnable() { @Override/* w w w . 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()); 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) { } } }); getCount.setPriority(7); getCount.start(); }
From source file:com.klinker.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 . c om*/ public void run() { boolean retweetedByMe; try { Twitter twitter = Utils.getTwitter(context, settings); 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.raythos.sentilexo.twitter.domain.QueryResultItemMapper.java
License:Apache License
public static Map getFieldsMapFromStatus(String queryOwner, String queryName, String queryString, Status status) { if (queryName != null) queryName = queryName.toLowerCase(); if (queryOwner != null) queryOwner = queryOwner.toLowerCase(); Map m = StatusArraysHelper.getUserMentionMap(status); Map newMap = new HashMap(); for (Object key : m.keySet()) { newMap.put(key.toString(), (Long) m.get(key)); }//from w ww . ja va2 s . co m Double longitude = null; Double lattitude = null; if (status.getGeoLocation() != null) { longitude = status.getGeoLocation().getLongitude(); lattitude = status.getGeoLocation().getLatitude(); } String place = null; if (status.getPlace() != null) { place = status.getPlace().getFullName(); } boolean isRetweet = status.getRetweetedStatus() != null; Long retweetedId = null; String retweetedText = null; if (isRetweet) { retweetedId = status.getRetweetedStatus().getId(); retweetedText = status.getRetweetedStatus().getText(); } Map<String, Object> result = new HashMap<>(); result.put(QueryResultItemFieldNames.STATUS_ID, status.getId()); result.put(QueryResultItemFieldNames.CREATED_AT, status.getCreatedAt()); result.put(QueryResultItemFieldNames.CURRENT_USER_RETWEET_ID, status.getCurrentUserRetweetId()); result.put(QueryResultItemFieldNames.FAVOURITE_COUNT, status.getFavoriteCount()); result.put(QueryResultItemFieldNames.FAVOURITED, status.isFavorited()); result.put(QueryResultItemFieldNames.HASHTAGS, StatusArraysHelper.getHashTagsList(status)); result.put(QueryResultItemFieldNames.IN_REPLY_TO_SCREEN_NAME, (status.getInReplyToScreenName())); result.put(QueryResultItemFieldNames.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId()); result.put(QueryResultItemFieldNames.IN_REPLY_TO_USER_ID, status.getInReplyToUserId()); result.put(QueryResultItemFieldNames.LATITUDE, lattitude); result.put(QueryResultItemFieldNames.LONGITUDE, longitude); result.put(QueryResultItemFieldNames.MENTIONS, newMap); result.put(QueryResultItemFieldNames.LANGUAGE, status.getLang()); result.put(QueryResultItemFieldNames.PLACE, place); result.put(QueryResultItemFieldNames.POSSIBLY_SENSITIVE, status.isPossiblySensitive()); result.put(QueryResultItemFieldNames.QUERY_NAME, queryName); result.put(QueryResultItemFieldNames.QUERY_OWNER, queryOwner); result.put(QueryResultItemFieldNames.QUERY, queryString); result.put(QueryResultItemFieldNames.RELEVANT_QUERY_TERMS, TwitterUtils.relevantQueryTermsFromStatus(queryString, status)); result.put(QueryResultItemFieldNames.RETWEET, isRetweet); result.put(QueryResultItemFieldNames.RETWEET_COUNT, status.getRetweetCount()); result.put(QueryResultItemFieldNames.RETWEETED, status.isRetweeted()); result.put(QueryResultItemFieldNames.RETWEETED_BY_ME, status.isRetweetedByMe()); result.put(QueryResultItemFieldNames.RETWEET_STATUS_ID, retweetedId); result.put(QueryResultItemFieldNames.RETWEETED_TEXT, retweetedText); result.put(QueryResultItemFieldNames.SCOPES, StatusArraysHelper.getScopesList(status)); result.put(QueryResultItemFieldNames.SCREEN_NAME, status.getUser().getScreenName()); result.put(QueryResultItemFieldNames.SOURCE, (status.getSource())); result.put(QueryResultItemFieldNames.TEXT, (status.getText())); result.put(QueryResultItemFieldNames.TRUNCATED, status.isTruncated()); result.put(QueryResultItemFieldNames.URLS, StatusArraysHelper.getUrlsList(status)); result.put(QueryResultItemFieldNames.USER_ID, status.getUser().getId()); result.put(QueryResultItemFieldNames.USER_NAME, (status.getUser().getName())); result.put(QueryResultItemFieldNames.USER_DESCRIPTION, (status.getUser().getDescription())); result.put(QueryResultItemFieldNames.USER_LOCATION, (status.getUser().getLocation())); result.put(QueryResultItemFieldNames.USER_URL, (status.getUser().getURL())); result.put(QueryResultItemFieldNames.USER_IS_PROTECTED, status.getUser().isProtected()); result.put(QueryResultItemFieldNames.USER_FOLLOWERS_COUNT, status.getUser().getFollowersCount()); result.put(QueryResultItemFieldNames.USER_CREATED_AT, status.getUser().getCreatedAt()); result.put(QueryResultItemFieldNames.USER_FRIENDS_COUNT, status.getUser().getFriendsCount()); result.put(QueryResultItemFieldNames.USER_LISTED_COUNT, status.getUser().getListedCount()); result.put(QueryResultItemFieldNames.USER_STATUSES_COUNT, status.getUser().getStatusesCount()); result.put(QueryResultItemFieldNames.USER_FAVOURITES_COUNT, status.getUser().getFavouritesCount()); return result; }
From source file:com.raythos.sentilexo.twitter.domain.QueryResultItemMapper.java
License:Apache License
public static TwitterQueryResultItemAvro mapItem(String queryOwner, String queryName, String queryString, Status status) { TwitterQueryResultItemAvro result = new TwitterQueryResultItemAvro(); if (queryName != null) queryName = queryName.toLowerCase(); if (queryOwner != null) queryOwner = queryOwner.toLowerCase(); result.setQueryName(queryName);/*from ww w .j a v a2s.c o m*/ result.setQueryOwner(queryOwner); result.setQuery(queryString); result.setStatusId(status.getId()); result.setText(status.getText()); result.setRelevantQueryTerms(TwitterUtils.relevantQueryTermsFromStatus(queryString, status)); result.setLang(status.getLang()); result.setCreatedAt(status.getCreatedAt().getTime()); User user = status.getUser(); result.setUserId(user.getId()); result.setScreenName(user.getScreenName()); result.setUserLocation(user.getLocation()); result.setUserName(user.getName()); result.setUserDescription(user.getDescription()); result.setUserIsProtected(user.isProtected()); result.setUserFollowersCount(user.getFollowersCount()); result.setUserCreatedAt(user.getCreatedAt().getTime()); result.setUserCreatedAtAsString(DateTimeUtils.getDateAsText(user.getCreatedAt())); result.setCreatedAtAsString(DateTimeUtils.getDateAsText(status.getCreatedAt())); result.setUserFriendsCount(user.getFriendsCount()); result.setUserListedCount(user.getListedCount()); result.setUserStatusesCount(user.getStatusesCount()); result.setUserFavoritesCount(user.getFavouritesCount()); result.setCurrentUserRetweetId(status.getCurrentUserRetweetId()); result.setInReplyToScreenName(status.getInReplyToScreenName()); result.setInReplyToStatusId(status.getInReplyToStatusId()); result.setInReplyToUserId(status.getInReplyToUserId()); if (status.getGeoLocation() != null) { result.setLatitude(status.getGeoLocation().getLatitude()); result.setLongitude(status.getGeoLocation().getLongitude()); } result.setSource(status.getSource()); result.setTrucated(status.isTruncated()); result.setPossiblySensitive(status.isPossiblySensitive()); result.setRetweet(status.getRetweetedStatus() != null); if (result.getRetweet()) { result.setRetweetStatusId(status.getRetweetedStatus().getId()); result.setRetweetedText(status.getRetweetedStatus().getText()); } result.setRetweeted(status.isRetweeted()); result.setRetweetCount(status.getRetweetCount()); result.setRetweetedByMe(status.isRetweetedByMe()); result.setFavoriteCount(status.getFavoriteCount()); result.setFavourited(status.isFavorited()); if (status.getPlace() != null) { result.setPlace(status.getPlace().getFullName()); } Scopes scopesObj = status.getScopes(); if (scopesObj != null) { List scopes = Arrays.asList(scopesObj.getPlaceIds()); result.setScopes(scopes); } return result; }