List of usage examples for twitter4j User getProfileImageURL
String getProfileImageURL();
From source file:com.twitt4droid.fragment.UserTimelineFragment.java
License:Apache License
/** * Sets up the user GUI./*from w w w . jav a 2 s.c o m*/ * * @param user the user. */ private void setUpUser(User user) { userScreenName.setText(user.getName()); if (!Strings.isNullOrBlank(user.getProfileBannerURL())) { new ImageLoader(getActivity()).setLoadingColorId(R.color.twitt4droid_no_image_background) .setImageView(userProfileBannerImage).execute(user.getProfileBannerURL()); } if (!Strings.isNullOrBlank(user.getProfileImageURL())) { new ImageLoader(getActivity()).setLoadingColorId(R.color.twitt4droid_no_image_background) .setImageView(userProfileImage).execute(user.getProfileImageURL()); } }
From source file:com.twitt4droid.widget.TweetDialog.java
License:Apache License
/** * Sets up the authenticated user./* w w w . ja va 2 s .co m*/ * * @param user the authenticated user. */ private void setUpUser(User user) { userUsername.setText(getContext().getString(R.string.twitt4droid_username_format, user.getScreenName())); userScreenName.setText(user.getName()); new ImageLoader(getContext()).setImageView(userProfileImage).execute(user.getProfileImageURL()); }
From source file:com.varaneckas.hawkscope.plugins.twitter.TwitterClient.java
License:Open Source License
/** * Gets an 24x24 image for User//from w w w. j a va2s .c o m * * @param user * @return */ public Image getUserImage(final User user) { if (user == null) { return getTwitterIcon(); } if (!userImages.containsKey(user.getName())) { final Configuration cfg = ConfigurationFactory.getConfigurationFactory().getConfiguration(); Image i = null; try { if (!cfg.isHttpProxyInUse()) { i = new Image(Display.getCurrent(), user.getProfileImageURL().openStream()); } else { Proxy p = new Proxy(Type.HTTP, InetSocketAddress.createUnresolved(cfg.getHttpProxyHost(), cfg.getHttpProxyPort())); URLConnection con = user.getProfileImageURL().openConnection(p); con.setReadTimeout(3000); i = new Image(Display.getCurrent(), con.getInputStream()); } i = new Image(Display.getCurrent(), i.getImageData().scaledTo(24, 24)); userImages.put(user.getName(), i); } catch (final IOException e) { log.warn("Failed getting user icon: " + user.getName(), e); return getTwitterIcon(); } } return userImages.get(user.getName()); }
From source file:com.vodafone.twitter.service.TwitterService.java
License:Apache License
private boolean processStatus(Status status) { if (msgWithSameId(status.getId()) != null) { if (Config.LOGD) Log.i(LOGTAG, "processStatus() found msgWithSameId " + status.getId() + " - don't process"); return false; }//from ww w . ja v a 2 s .c o m boolean newMsgReceived = false; User user = status.getUser(); String channelImageString = null; try { java.net.URI uri = user.getProfileImageURL().toURI(); channelImageString = uri.toString(); } catch (java.net.URISyntaxException uriex) { Log.e(LOGTAG, String.format("ConnectThread processStatus() URISyntaxException %s ex=%s", user.getProfileImageURL().toString(), uriex)); errMsg = uriex.getMessage(); } String title = status.getText(); if (linkifyMessages) { title = linkify(title, null, true); // messageLink will contain the link-url } long timeMs = status.getCreatedAt().getTime(); // make timeMs unique in our messageList while (findIdxOfMsgWithSameTimeMs(timeMs) >= 0) timeMs++; EntryTopic feedEntry = new EntryTopic(0, 0, user.getName(), title, null, messageLink, timeMs, status.getId(), channelImageString); feedEntry.shortName = user.getScreenName(); synchronized (messageList) { // messageList is always sorted with the newest items on top int findIdxOfFirstOlder = findIdxOfFirstOlderMsg(feedEntry); if (findIdxOfFirstOlder < maxQueueMessages) { messageList.add(findIdxOfFirstOlder, feedEntry); newMsgReceived = true; totalNumberOfQueuedMessages++; if (activityPaused) numberOfQueuedMessagesSinceLastClientActivity++; // debug: for every regular msg, create 5 additional dummy messages //for(int i=1; i<=5; i++) { // feedEntry = new EntryTopic(0, // region // 0, // prio // "dummy", // "test message "+i, // null, // description // messageLink, // timeMs+i*100, // status.getId()+i, // todo: make sure the id was ot yet stored in messageList // channelImageString); // todo: must make use of this in MyWebView/JsObject/script.js // messageList.add(findIdxOfFirstOlder,feedEntry); // totalNumberOfQueuedMessages++; // if(activityPaused) // numberOfQueuedMessagesSinceLastClientActivity++; //} // if there are now more than 'maxQueueMessages' entrys in the queue, remove the oldest... while (messageList.size() > maxQueueMessages) messageList.removeLast(); } else { if (Config.LOGD) Log.i(LOGTAG, "processStatus() not findIdxOfFirstOlder<maxQueueMessages - don't process"); } } return newMsgReceived; }
From source file:de.jetwick.data.JUser.java
License:Apache License
/** * This method refreshes the properties of this user by the specified * Twitter4j user//from ww w.ja va 2 s .c o m * @param user */ public Status updateFieldsBy(User user) { twitterId = user.getId(); setProtected(user.isProtected()); setTwitterCreatedAt(user.getCreatedAt()); setDescription(user.getDescription()); addLanguage(user.getLang()); setLocation(TwitterSearch.toStandardLocation(user.getLocation())); setRealName(user.getName()); // user.getFollowersCount(); // user.getFriendsCount(); // user.getTimeZone() if (user.getProfileImageURL() != null) setProfileImageUrl(user.getProfileImageURL().toString()); if (user.getURL() != null) setWebUrl(user.getURL().toString()); setFollowersCount(user.getFollowersCount()); setFriendsCount(user.getFriendsCount()); return user.getStatus(); }
From source file:de.jetwick.tw.TwitterSearch.java
License:Apache License
public static Twitter4JTweet toTweet(Status st, User user) { if (user == null) throw new IllegalArgumentException("User mustn't be null!"); if (st == null) throw new IllegalArgumentException("Status mustn't be null!"); Twitter4JTweet tw = new Twitter4JTweet(st.getId(), st.getText(), user.getScreenName()); tw.setCreatedAt(st.getCreatedAt());//from w w w . ja v a 2 s .c o m tw.setFromUser(user.getScreenName()); if (user.getProfileImageURL() != null) tw.setProfileImageUrl(user.getProfileImageURL().toString()); tw.setSource(st.getSource()); tw.setToUser(st.getInReplyToUserId(), st.getInReplyToScreenName()); tw.setInReplyToStatusId(st.getInReplyToStatusId()); if (st.getGeoLocation() != null) { tw.setGeoLocation(st.getGeoLocation()); tw.setLocation(st.getGeoLocation().getLatitude() + ", " + st.getGeoLocation().getLongitude()); } else if (st.getPlace() != null) tw.setLocation(st.getPlace().getCountryCode()); else if (user.getLocation() != null) tw.setLocation(toStandardLocation(user.getLocation())); return tw; }
From source file:h2weibo.controllers.UserServlet.java
License:Open Source License
@Override protected Template handleRequest(HttpServletRequest request, HttpServletResponse response, Context ctx) { HttpServletRouter r = new HttpServletRouter(request); r.setPattern("/:id"); HttpSession session = request.getSession(false); DBHelper helper = (DBHelper) request.getAttribute(Keys.REQUEST_DB_HELPER); // Service limit String uId = r.get(":id"); if (!helper.isUser(uId) && helper.getUserCount() > 50) { return getTemplate("full.vm"); }// ww w. j a v a 2 s .c om T2WUser user = helper.findOneByUser(uId); if (r.has(":id")) { log.info("Displaying user info for @" + uId); ctx.put("user_id", uId); ctx.put("user", helper.findOneByUser(uId)); try { weibo4j.User weiboUser = (weibo4j.User) session.getAttribute(Keys.SESSION_WEIBO_USER); if (weiboUser == null) { Weibo w = new Weibo(); w.setToken(user.getToken(), user.getTokenSecret()); weiboUser = w.verifyCredentials(); session.setAttribute(Keys.SESSION_WEIBO_USER, weiboUser); } ctx.put("weibo_user", weiboUser.getScreenName()); ctx.put("weibo_user_image", weiboUser.getProfileImageURL().toString()); ctx.put("weibo_login", 1); // save weiboUser ID mapping helper.setWeiboId(user.getUserId(), weiboUser.getScreenName()); } catch (Exception e) { // 401 = not logged in if (e instanceof WeiboException && ((WeiboException) e).getStatusCode() != 401) { e.printStackTrace(); } } try { twitter4j.User twitterUser = (twitter4j.User) session.getAttribute(Keys.SESSION_TWITTER_USER); if (twitterUser == null) { TwitterFactory factory = new TwitterFactory(); Twitter t = factory.getInstance(); t.setOAuthAccessToken(new AccessToken(user.getTwitterToken(), user.getTwitterTokenSecret())); twitterUser = t.verifyCredentials(); session.setAttribute(Keys.SESSION_TWITTER_USER, twitterUser); } ctx.put("twitter_user", twitterUser.getScreenName()); ctx.put("twitter_user_image", twitterUser.getProfileImageURL().toString()); ctx.put("twitter_login", 1); } catch (Exception e) { // 401 = not logged in if (e instanceof TwitterException && ((TwitterException) e).getStatusCode() != 401) { e.printStackTrace(); } } } Object message = session.getAttribute(Keys.SESSION_MESSAGE); if (message != null) { ctx.put("message", message); session.removeAttribute(Keys.SESSION_MESSAGE); } Object prompt = session.getAttribute(Keys.SESSION_PROMPT_TWEET); if (prompt != null) { ctx.put("prompt", prompt); session.removeAttribute(Keys.SESSION_PROMPT_TWEET); } return getTemplate("user.vm"); }
From source file:jp.gr.java_conf.ya.shiobeforandroid3.UpdateTweetMultiple.java
License:Open Source License
private final String init_user_oauth(final int index) { oauthToken = MyCrypt.decrypt(this, crpKey, pref_twtr.getString("oauth_token_" + index, "")); if (oauthToken.equals("")) { WriteLog.write(this, "oauthToken.equals(\"\")"); final SharedPreferences.Editor editor = pref_twtr.edit(); editor.putString("index", "0"); editor.remove("consumer_key_" + index); editor.remove("consumer_secret_" + index); editor.remove("oauth_token_" + index); editor.remove("oauth_token_secret_" + index); editor.remove("profile_image_url_" + index); editor.remove("screen_name_" + index); editor.remove("status_" + index); editor.commit();/*from ww w . j a v a 2 s . c o m*/ } consumerKey = MyCrypt.decrypt(this, crpKey, pref_twtr.getString("consumer_key_" + index, "")); consumerSecret = MyCrypt.decrypt(this, crpKey, pref_twtr.getString("consumer_secret_" + index, "")); if (consumerKey.equals("") || consumerSecret.equals("")) { WriteLog.write(this, "(consumerKey.equals(\"\") || consumerSecret.equals(\"\"))"); consumerKey = getString(R.string.default_consumerKey); consumerSecret = getString(R.string.default_consumerSecret); } pref_app = PreferenceManager.getDefaultSharedPreferences(this); pref_timeout_t4j_connection = ListAdapter.getPrefInt(this, "pref_timeout_t4j_connection", "20000"); pref_timeout_t4j_read = ListAdapter.getPrefInt(this, "pref_timeout_t4j_read", "120000"); oauthTokenSecret = MyCrypt.decrypt(this, crpKey, pref_twtr.getString("oauth_token_secret_" + index, "")); try { confbuilder = new ConfigurationBuilder(); } catch (final IllegalStateException e) { WriteLog.write(this, e); } catch (final Exception e) { WriteLog.write(this, e); } confbuilder.setOAuthAccessToken(oauthToken).setOAuthAccessTokenSecret(oauthTokenSecret) .setOAuthConsumerKey(consumerKey).setOAuthConsumerSecret(consumerSecret) .setHttpConnectionTimeout(pref_timeout_t4j_connection).setHttpReadTimeout(pref_timeout_t4j_read) .setHttpRetryCount(3).setHttpRetryIntervalSeconds(10);// .setUseSSL(true); Twitter twtr; try { conf = confbuilder.build(); twtr = new TwitterFactory(conf).getInstance(); } catch (final Exception e) { twtr = null; WriteLog.write(this, e); adapter.toast(getString(R.string.cannot_access_twitter) + System.getProperty("line.separator") + getString(R.string.tryagain_oauth)); } WriteLog.write(this, "init_user_oauth(): conf: " + conf.toString()); WriteLog.write(this, "init_user_oauth(): twtr: " + twtr.toString()); if (twtr != null) { try { screenName = twtr.getScreenName(); User user = twtr.showUser(screenName); final String profile_image_url = user.getProfileImageURL().toString(); pref_twtr = getSharedPreferences("Twitter_setting", MODE_PRIVATE); final SharedPreferences.Editor editor = pref_twtr.edit(); editor.putString("screen_name_" + index, screenName); editor.putString("profile_image_url_" + index, profile_image_url); editor.commit(); WriteLog.write(this, "screenName: " + screenName); WriteLog.write(this, "profile_image_url: " + profile_image_url); } catch (final TwitterException e) { WriteLog.write(this, e); adapter.toast(getString(R.string.cannot_access_twitter) + System.getProperty("line.separator") + getString(R.string.tryagain_oauth)); } catch (final Exception e) { WriteLog.write(this, e); adapter.toast(getString(R.string.cannot_access_twitter) + System.getProperty("line.separator") + getString(R.string.tryagain_oauth)); } } return screenName; }
From source file:net.firejack.platform.web.security.twitter.BaseTwitterAuthenticationProcessor.java
License:Apache License
protected Map<String, String> getTwitterUserInformation(Twitter twitterService) throws TwitterException { Map<String, String> userInfo = new HashMap<String, String>(); long id = twitterService.getId(); userInfo.put(TW_USER_ID, String.valueOf(id)); String screenName = twitterService.getScreenName(); userInfo.put(TW_SCREEN_NAME, screenName); twitter4j.User user = twitterService.showUser(id); userInfo.put(TW_US_SCREEN_NAME, user.getScreenName()); userInfo.put(TW_US_NAME, user.getName()); userInfo.put(TW_US_PROFILE_IMAGE_URL, user.getProfileImageURL()); return userInfo; }
From source file:net.lacolaco.smileessence.viewmodel.EventViewModel.java
License:Open Source License
public EventViewModel(EnumEvent event, User source, Status status) { this.event = event; this.createdAt = new Date(); this.sourceUserID = source.getId(); this.sourceScreenName = source.getScreenName(); this.sourceName = source.getName(); this.iconURL = source.getProfileImageURL(); if (status != null) { if (event == EnumEvent.RETWEETED) { this.targetStatusID = status.getRetweetedStatus().getId(); this.targetText = status.getRetweetedStatus().getText(); } else {//from ww w . j a v a 2 s . co m this.targetStatusID = status.getId(); this.targetText = status.getText(); } } else { this.targetStatusID = -1L; this.targetText = ""; } }