List of usage examples for twitter4j User getScreenName
String getScreenName();
From source file:com.freshdigitable.udonroad.UserInfoActivity.java
License:Apache License
public static void bindUserScreenName(TextView textView, User user) { final Resources resources = textView.getContext().getResources(); textView.setText(String.format(resources.getString(R.string.tweet_name), user.getScreenName())); }
From source file:com.freshdigitable.udonroad.util.UserUtil.java
License:Apache License
public static User create() { final User mock = mock(User.class); when(mock.getScreenName()).thenReturn("akihito104"); when(mock.getName()).thenReturn("Akihito Matsuda"); when(mock.getId()).thenReturn(2000L); when(mock.getProfileBackgroundColor()).thenReturn("ffffff"); when(mock.getDescription()).thenReturn("user description is here."); when(mock.getDescriptionURLEntities()).thenReturn(new URLEntity[0]); when(mock.getURL()).thenReturn(null); when(mock.getLocation()).thenReturn(null); return mock;/*from www . ja v a 2s . c o m*/ }
From source file:com.github.daytron.twaattin.ui.tabledecorator.ScreenNameColumnGenerator.java
License:Open Source License
/** * @param source/*www . j av a2 s . c o m*/ * @param itemId * @param columnId * @return Screen name of the underlying {@link User} as a {@link Link} * component. */ @Override public Object generateCell(Table source, Object itemId, Object columnId) { User user = getUser(source, itemId); ExternalResource resource = new ExternalResource(TWITTER_USER_URL + user.getScreenName()); Link link = new Link('@' + user.getScreenName(), resource); link.setTargetName("screenname"); return link; }
From source file:com.github.gorbin.asne.twitter.TwitterSocialNetwork.java
License:Open Source License
private TwitterPerson getDetailedSocialPerson(TwitterPerson twitterPerson, User user) { getSocialPerson(twitterPerson, user); twitterPerson.createdDate = user.getCreatedAt().getTime(); twitterPerson.description = user.getDescription(); twitterPerson.favoritesCount = user.getFavouritesCount(); twitterPerson.followersCount = user.getFollowersCount(); twitterPerson.friendsCount = user.getFriendsCount(); twitterPerson.lang = user.getLang(); twitterPerson.location = user.getLocation(); twitterPerson.screenName = user.getScreenName(); if (user.getStatus() != null) { twitterPerson.status = user.getStatus().getText(); } else {//from w ww. ja va2s .c o m twitterPerson.status = null; } twitterPerson.timezone = user.getTimeZone(); twitterPerson.isTranslator = user.isTranslator(); twitterPerson.isVerified = user.isVerified(); return twitterPerson; }
From source file:com.github.jcustenborder.kafka.connect.twitter.StatusConverter.java
License:Apache License
public static void convert(User user, Struct struct) { struct.put("Id", user.getId()).put("Name", user.getName()).put("ScreenName", user.getScreenName()) .put("Location", user.getLocation()).put("Description", user.getDescription()) .put("ContributorsEnabled", user.isContributorsEnabled()) .put("ProfileImageURL", user.getProfileImageURL()) .put("BiggerProfileImageURL", user.getBiggerProfileImageURL()) .put("MiniProfileImageURL", user.getMiniProfileImageURL()) .put("OriginalProfileImageURL", user.getOriginalProfileImageURL()) .put("ProfileImageURLHttps", user.getProfileImageURLHttps()) .put("BiggerProfileImageURLHttps", user.getBiggerProfileImageURLHttps()) .put("MiniProfileImageURLHttps", user.getMiniProfileImageURLHttps()) .put("OriginalProfileImageURLHttps", user.getOriginalProfileImageURLHttps()) .put("DefaultProfileImage", user.isDefaultProfileImage()).put("URL", user.getURL()) .put("Protected", user.isProtected()).put("FollowersCount", user.getFollowersCount()) .put("ProfileBackgroundColor", user.getProfileBackgroundColor()) .put("ProfileTextColor", user.getProfileTextColor()) .put("ProfileLinkColor", user.getProfileLinkColor()) .put("ProfileSidebarFillColor", user.getProfileSidebarFillColor()) .put("ProfileSidebarBorderColor", user.getProfileSidebarBorderColor()) .put("ProfileUseBackgroundImage", user.isProfileUseBackgroundImage()) .put("DefaultProfile", user.isDefaultProfile()) .put("ShowAllInlineMedia", user.isShowAllInlineMedia()).put("FriendsCount", user.getFriendsCount()) .put("CreatedAt", user.getCreatedAt()).put("FavouritesCount", user.getFavouritesCount()) .put("UtcOffset", user.getUtcOffset()).put("TimeZone", user.getTimeZone()) .put("ProfileBackgroundImageURL", user.getProfileBackgroundImageURL()) .put("ProfileBackgroundImageUrlHttps", user.getProfileBackgroundImageUrlHttps()) .put("ProfileBannerURL", user.getProfileBannerURL()) .put("ProfileBannerRetinaURL", user.getProfileBannerRetinaURL()) .put("ProfileBannerIPadURL", user.getProfileBannerIPadURL()) .put("ProfileBannerIPadRetinaURL", user.getProfileBannerIPadRetinaURL()) .put("ProfileBannerMobileURL", user.getProfileBannerMobileURL()) .put("ProfileBannerMobileRetinaURL", user.getProfileBannerMobileRetinaURL()) .put("ProfileBackgroundTiled", user.isProfileBackgroundTiled()).put("Lang", user.getLang()) .put("StatusesCount", user.getStatusesCount()).put("GeoEnabled", user.isGeoEnabled()) .put("Verified", user.isVerified()).put("Translator", user.isTranslator()) .put("ListedCount", user.getListedCount()).put("FollowRequestSent", user.isFollowRequestSent()); List<String> withheldInCountries = new ArrayList<>(); if (null != user.getWithheldInCountries()) { for (String s : user.getWithheldInCountries()) { withheldInCountries.add(s);//ww w . j av a2 s . c o m } } struct.put("WithheldInCountries", withheldInCountries); }
From source file:com.google.appinventor.components.runtime.Twitter.java
License:Open Source License
/** * Check whether accessToken is stored in preferences. If there is one, set it. * If it was already set (for instance calling Authorize twice in a row), * it will throw an IllegalStateException that, in this case, can be ignored. * @return true if accessToken is valid and set (user authorized), false otherwise. *//*from w ww . j a v a 2 s .c om*/ private boolean checkAccessToken(String myConsumerKey, String myConsumerSecret) { accessToken = retrieveAccessToken(); if (accessToken == null) { return false; } else { if (twitter == null) { twitter = new TwitterFactory().getInstance(); } try { twitter.setOAuthConsumer(consumerKey, consumerSecret); twitter.setOAuthAccessToken(accessToken); } catch (IllegalStateException ies) { //ignore: it means that the consumer data was already set } if (userName.trim().length() == 0) { User user; try { user = twitter.verifyCredentials(); userName = user.getScreenName(); } catch (TwitterException e) {// something went wrong (networks or bad credentials <-- DeAuthorize deAuthorize(); return false; } } return true; } }
From source file:com.ikungolf.java.javatwitter.GetHomeTimeline.java
License:Apache License
/** * Usage: java twitter4j.examples.timeline.GetHomeTimeline * * @param args String[]/*from ww w .jav a 2s . c o m*/ */ public static void main(String[] args) { try { // gets Twitter instance with default credentials Twitter twitter = new TwitterFactory().getInstance(); User user = twitter.verifyCredentials(); List<Status> statuses = twitter.getHomeTimeline(); System.out.println("Showing @" + user.getScreenName() + "'s home timeline."); for (Status status : statuses) { System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText()); } } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get timeline: " + te.getMessage()); System.exit(-1); } }
From source file:com.ikungolf.java.javatwitter.GetMentions.java
License:Apache License
/** * Usage: java twitter4j.examples.timeline.GetMentions * * @param args String[]//from w ww .j a va2 s.com */ public static void main(String[] args) { // gets Twitter instance with default credentials Twitter twitter = new TwitterFactory().getInstance(); try { User user = twitter.verifyCredentials(); List<Status> statuses = twitter.getMentionsTimeline(); System.out.println("Showing @" + user.getScreenName() + "'s mentions."); for (Status status : statuses) { System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText()); } } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get timeline: " + te.getMessage()); System.exit(-1); } }
From source file:com.industrialtsi.mylyn.twitter.persistor.TwitterPersistor.java
License:Open Source License
@Override public List<String> getLegalOwners(TaskRepository repository) throws SQLException, CoreException { Twitter t = getTwitter(repository);/*from ww w . j a v a 2 s . c o m*/ List<String> result = new ArrayList<String>(); List<User> friends; try { friends = t.getFriendsStatuses(); for (User friend : friends) { result.add(friend.getName() + " (" + friend.getScreenName() + ")"); } Object[] res = result.toArray(); Arrays.sort(res); result = new ArrayList<String>(); for (Object object : res) { result.add((String) object); } return result; } catch (TwitterException e) { IStatus status = CoreLogger.createStatus(IStatus.ERROR, e); throw new CoreException(status); } }
From source file:com.javielinux.api.loaders.LoadMoreTweetDownLoader.java
License:Apache License
@Override public BaseResponse loadInBackground() { try {/*from ww w. ja v a 2s .c om*/ LoadMoreTweetDownResponse response = new LoadMoreTweetDownResponse(); PreferenceManager.setDefaultValues(getContext(), R.xml.preferences, false); SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getContext()); int maxDownloadTweet = Integer.parseInt(pref.getString("prf_n_max_download", "60")); if (maxDownloadTweet <= 0) maxDownloadTweet = 60; ConnectionManager.getInstance().open(getContext()); Twitter twitter = ConnectionManager.getInstance().getTwitter(request.getUserId()); Paging p = new Paging(); p.setCount(maxDownloadTweet); p.setSinceId(request.getSinceId()); p.setMaxId(request.getMaxId()); ResponseList<Status> statii = null; try { statii = twitter.getHomeTimeline(p); } catch (OutOfMemoryError e) { e.printStackTrace(); } boolean breakTimeline = false; if (statii != null && statii.size() >= maxDownloadTweet - 10) { p = new Paging(1, 10); p.setSinceId(request.getSinceId()); p.setMaxId(statii.get(statii.size() - 1).getId()); if (twitter.getHomeTimeline().size() > 0) { breakTimeline = true; response.setHasMoreTweets(true); } } if (statii != null) { if (statii.size() > 0) { try { DataFramework.getInstance().open(getContext(), Utils.packageName); } catch (Exception e) { e.printStackTrace(); } List<InfoTweet> tweets = new ArrayList<InfoTweet>(); for (Status status : statii) { tweets.add(new InfoTweet(status)); } response.setTweets(tweets); long nextId = 1; Cursor c = DataFramework.getInstance().getCursor("tweets_user", new String[] { DataFramework.KEY_ID }, null, null, null, null, DataFramework.KEY_ID + " desc", "1"); if (!c.moveToFirst()) { c.close(); nextId = 1; } else { long Id = c.getInt(0) + 1; c.close(); nextId = Id; } try { boolean isFirst = true; for (int i = statii.size() - 1; i >= 0; i--) { User u = statii.get(i).getUser(); if (u != null) { ContentValues args = new ContentValues(); args.put(DataFramework.KEY_ID, "" + nextId); args.put("type_id", TweetTopicsUtils.TWEET_TYPE_TIMELINE); args.put("user_tt_id", "" + request.getUserId()); if (u.getProfileImageURL() != null) { args.put("url_avatar", u.getProfileImageURL().toString()); } else { args.put("url_avatar", ""); } args.put("username", u.getScreenName()); args.put("fullname", u.getName()); args.put("user_id", "" + u.getId()); args.put("tweet_id", Utils.fillZeros("" + statii.get(i).getId())); args.put("source", statii.get(i).getSource()); args.put("to_username", statii.get(i).getInReplyToScreenName()); args.put("to_user_id", "" + statii.get(i).getInReplyToUserId()); args.put("date", String.valueOf(statii.get(i).getCreatedAt().getTime())); if (statii.get(i).getRetweetedStatus() != null) { args.put("is_retweet", 1); args.put("retweet_url_avatar", statii.get(i).getRetweetedStatus().getUser() .getProfileImageURL().toString()); args.put("retweet_username", statii.get(i).getRetweetedStatus().getUser().getScreenName()); args.put("retweet_source", statii.get(i).getRetweetedStatus().getSource()); String t = Utils.getTwitLoger(statii.get(i).getRetweetedStatus()); if (t.equals("")) { args.put("text", statii.get(i).getRetweetedStatus().getText()); args.put("text_urls", Utils.getTextURLs(statii.get(i).getRetweetedStatus())); } else { args.put("text", t); } args.put("is_favorite", 0); } else { String t = Utils.getTwitLoger(statii.get(i)); if (t.equals("")) { args.put("text", statii.get(i).getText()); args.put("text_urls", Utils.getTextURLs(statii.get(i))); } else { args.put("text", t); } if (statii.get(i).isFavorited()) { args.put("is_favorite", 1); } } if (statii.get(i).getGeoLocation() != null) { args.put("latitude", statii.get(i).getGeoLocation().getLatitude()); args.put("longitude", statii.get(i).getGeoLocation().getLongitude()); } args.put("reply_tweet_id", statii.get(i).getInReplyToStatusId()); if (breakTimeline && isFirst) args.put("has_more_tweets_down", 1); DataFramework.getInstance().getDB().insert("tweets_user", null, args); nextId++; if (isFirst) isFirst = false; } } } catch (SQLException e) { e.printStackTrace(); } DataFramework.getInstance().close(); } } return response; } catch (TwitterException twitterException) { twitterException.printStackTrace(); ErrorResponse errorResponse = new ErrorResponse(); errorResponse.setError(twitterException, twitterException.getMessage()); return errorResponse; } catch (Exception exception) { exception.printStackTrace(); ErrorResponse errorResponse = new ErrorResponse(); errorResponse.setError(exception, exception.getMessage()); return errorResponse; } }