List of usage examples for twitter4j Status getFavoriteCount
int getFavoriteCount();
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 w w.ja v a 2s . c o 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; }//ww w.j av a 2 s . co 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 bindFavorite(Status bindingStatus) { final int favCount = bindingStatus.getFavoriteCount(); if (favCount > 0) { this.setFavCountVisibility(VISIBLE); setTint(favIcon,/*from w w w .j a va 2 s. co m*/ bindingStatus.isFavorited() ? R.color.twitter_action_faved : R.color.twitter_action_normal); this.favCount.setText(String.valueOf(favCount)); } }
From source file:com.freshdigitable.udonroad.TimelineInstTestBase.java
License:Apache License
protected void setupCreateFavorite(final int rtCount, final int favCount) throws TwitterException { when(twitter.createFavorite(anyLong())).thenAnswer(new Answer<Status>() { @Override//from w ww .j a v a 2s .co m public Status answer(InvocationOnMock invocation) throws Throwable { final Long id = invocation.getArgumentAt(0, Long.class); final Status status = findByStatusId(id); when(status.getFavoriteCount()).thenReturn(favCount); when(status.getRetweetCount()).thenReturn(rtCount); when(status.isFavorited()).thenReturn(true); return status; } }); }
From source file:com.freshdigitable.udonroad.util.TwitterResponseMock.java
License:Apache License
public static Status createRtStatus(Status rtedStatus, long newStatusId, int rtCount, int favCount, boolean isFromRest) { final Status rtStatus = createStatus(rtedStatus.getId(), rtedStatus.getUser()); if (isFromRest) { when(rtStatus.isRetweeted()).thenReturn(true); when(rtStatus.getRetweetCount()).thenReturn(rtCount); when(rtStatus.getFavoriteCount()).thenReturn(favCount); } else {/*from ww w . j a v a 2s . c o m*/ when(rtStatus.isRetweeted()).thenReturn(false); when(rtStatus.getRetweetCount()).thenReturn(0); when(rtStatus.getFavoriteCount()).thenReturn(0); } final Status status = createStatus(newStatusId); final String rtText = rtStatus.getText(); when(status.getText()).thenReturn(rtText); when(status.isRetweet()).thenReturn(true); when(status.isRetweeted()).thenReturn(isFromRest); when(status.getRetweetedStatus()).thenReturn(rtStatus); return status; }
From source file:com.fsatir.twitter.TwitterManagedBean.java
public List<Media> trendImageList(Twitter twitter, String trendName) { Query query = new Query(trendName + " AND filter:images"); query.setCount(1);/*from ww w. j av a 2 s . c o m*/ QueryResult result; try { do { result = twitter.search(query); List<twitter4j.Status> tweets = result.getTweets(); int counter = 0; for (twitter4j.Status status : tweets) { Media myMedia = new Media(); int control = 0; for (MediaEntity me : status.getMediaEntities()) { //Tek grsel almay kesinletirmek iin kontrol. //leride modeldeki trendImgURL diziye dntrlerek kontrol kaldrlabilir. if (control < 1) myMedia.setTrendImgURL(me.getMediaURLHttps()); control++; } // URL null deilse, grsel ve bigileri list'e eklenir. if (myMedia.getTrendImgURL() != null) { myMedia.setTweetID(status.getId()); myMedia.setFavorite_count(status.getFavoriteCount()); myMedia.setRetweet_count(status.getRetweetCount()); //myMedia.setTrendImgURL(status.getMediaEntities()[0].getMediaURLHttps()); myMedia.setTrendName(trendName); myMedia.setName(Long.toString(status.getId())); myMedia.setType(status.getMediaEntities()[0].getType()); myMediaList.add(counter++, myMedia); } } } while ((query = result.nextQuery()) != null && result.getRateLimitStatus().getRemaining() > 0); } catch (TwitterException e) { e.printStackTrace(); } myMediaListFiltered = filterList(myMediaList); return myMediaListFiltered; }
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 ww w . j av a 2s.co 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.activities.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/* w ww . j ava 2 s .com*/ 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() { 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("talon_image", s); } if (images.size() > 1) { Log.v("talon_images", "size: " + images.size()); try { mAttacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() { @Override public void onViewTap(View view, float x, float y) { Intent viewPics = new Intent(context, ViewPictures.class); viewPics.putExtra("images", images); startActivity(viewPics); } }); } catch (Exception e) { // addon theme without the attacher profilePic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent viewPics = new Intent(context, ViewPictures.class); viewPics.putExtra("images", images); startActivity(viewPics); } }); } } } }); } catch (Exception e) { } } }); getInfo.setPriority(Thread.MAX_PRIORITY); getInfo.start(); }
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/*from w w w. ja va2s. 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 getFavoriteCount(final TextView favs, final View favButton, final long tweetId) { new Thread(new Runnable() { @Override/* w ww . j a va 2s. c om*/ public void run() { try { Twitter twitter = Utils.getTwitter(context, settings); 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(); }