List of usage examples for twitter4j Status getText
String getText();
From source file:com.klinker.android.twitter.adapters.TimelineArrayAdapter.java
License:Apache License
public void bindView(final View view, Status status, int position) { final ViewHolder holder = (ViewHolder) view.getTag(); if (holder.expandArea.getVisibility() == View.VISIBLE) { removeExpansionNoAnimation(holder); }/* w ww . j av a 2 s.co m*/ Status thisStatus; String retweeter; final long time = status.getCreatedAt().getTime(); long originalTime = 0; if (status.isRetweet()) { retweeter = status.getUser().getScreenName(); thisStatus = status.getRetweetedStatus(); originalTime = thisStatus.getCreatedAt().getTime(); } else { retweeter = ""; thisStatus = status; } final long fOriginalTime = originalTime; User user = thisStatus.getUser(); holder.tweetId = thisStatus.getId(); final long id = holder.tweetId; final String profilePic = user.getOriginalProfileImageURL(); String tweetTexts = thisStatus.getText(); final String name = user.getName(); final String screenname = user.getScreenName(); String[] html = TweetLinkUtils.getLinksInStatus(thisStatus); final String tweetText = html[0]; final String picUrl = html[1]; holder.picUrl = picUrl; final String otherUrl = html[2]; final String hashtags = html[3]; final String users = html[4]; if (!settings.reverseClickActions) { final String fRetweeter = retweeter; holder.background.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { String link; boolean displayPic = !holder.picUrl.equals("") && !holder.picUrl.contains("youtube"); if (displayPic) { link = holder.picUrl; } else { link = otherUrl.split(" ")[0]; } Log.v("tweet_page", "clicked"); Intent viewTweet = new Intent(context, TweetPager.class); viewTweet.putExtra("name", name); viewTweet.putExtra("screenname", screenname); viewTweet.putExtra("time", time); viewTweet.putExtra("tweet", tweetText); viewTweet.putExtra("retweeter", fRetweeter); viewTweet.putExtra("webpage", link); viewTweet.putExtra("other_links", otherUrl); viewTweet.putExtra("picture", displayPic); viewTweet.putExtra("tweetid", holder.tweetId); viewTweet.putExtra("proPic", profilePic); viewTweet.putExtra("users", users); viewTweet.putExtra("hashtags", hashtags); context.startActivity(viewTweet); return true; } }); holder.background.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (holder.preventNextClick) { holder.preventNextClick = false; return; } if (holder.expandArea.getVisibility() == View.GONE) { addExpansion(holder, screenname, users, otherUrl.split(" "), holder.picUrl, id); } else { removeExpansionWithAnimation(holder); removeKeyboard(holder); } } }); } else { final String fRetweeter = retweeter; holder.background.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (holder.preventNextClick) { holder.preventNextClick = false; return; } String link; boolean displayPic = !holder.picUrl.equals("") && !holder.picUrl.contains("youtube"); if (displayPic) { link = holder.picUrl; } else { link = otherUrl.split(" ")[0]; } Log.v("tweet_page", "clicked"); Intent viewTweet = new Intent(context, TweetPager.class); viewTweet.putExtra("name", name); viewTweet.putExtra("screenname", screenname); viewTweet.putExtra("time", time); viewTweet.putExtra("tweet", tweetText); viewTweet.putExtra("retweeter", fRetweeter); viewTweet.putExtra("webpage", link); viewTweet.putExtra("other_links", otherUrl); viewTweet.putExtra("picture", displayPic); viewTweet.putExtra("tweetid", holder.tweetId); viewTweet.putExtra("proPic", profilePic); viewTweet.putExtra("users", users); viewTweet.putExtra("hashtags", hashtags); context.startActivity(viewTweet); } }); holder.background.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { if (holder.expandArea.getVisibility() == View.GONE) { addExpansion(holder, screenname, users, otherUrl.split(" "), holder.picUrl, id); } else { removeExpansionWithAnimation(holder); removeKeyboard(holder); } return true; } }); } if (!screenname.equals(username)) { holder.profilePic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent viewProfile = new Intent(context, ProfilePager.class); viewProfile.putExtra("name", name); viewProfile.putExtra("screenname", screenname); viewProfile.putExtra("proPic", profilePic); viewProfile.putExtra("tweetid", holder.tweetId); viewProfile.putExtra("retweet", holder.retweeter.getVisibility() == View.VISIBLE); viewProfile.putExtra("long_click", false); context.startActivity(viewProfile); } }); holder.profilePic.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { Intent viewProfile = new Intent(context, ProfilePager.class); viewProfile.putExtra("name", name); viewProfile.putExtra("screenname", screenname); viewProfile.putExtra("proPic", profilePic); viewProfile.putExtra("tweetid", holder.tweetId); viewProfile.putExtra("retweet", holder.retweeter.getVisibility() == View.VISIBLE); viewProfile.putExtra("long_click", true); context.startActivity(viewProfile); return false; } }); } else { // need to clear the click listener so it isn't left over from another profile holder.profilePic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); holder.profilePic.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { return true; } }); } if (talonLayout == AppSettings.LAYOUT_FULL_SCREEN || (settings.nameAndHandleOnTweet && settings.addonTheme)) { if (holder.screenTV.getVisibility() == View.GONE) { holder.screenTV.setVisibility(View.VISIBLE); } holder.screenTV.setText("@" + screenname); holder.name.setText(name); } else { if (!settings.showBoth) { holder.name.setText(settings.displayScreenName ? "@" + screenname : name); } else { if (holder.screenTV.getVisibility() == View.GONE) { holder.screenTV.setVisibility(View.VISIBLE); } holder.name.setText(name); holder.screenTV.setText("@" + screenname); } } if (!settings.absoluteDate) { holder.time.setText(Utils.getTimeAgo(time, context)); } else { Date date = new Date(time); holder.time .setText(timeFormatter.format(date).replace("24:", "00:") + ", " + dateFormatter.format(date)); } holder.tweet.setText(tweetText); boolean picture = false; if (settings.inlinePics) { if (holder.picUrl.equals("")) { if (holder.image.getVisibility() != View.GONE) { holder.image.setVisibility(View.GONE); } if (holder.playButton.getVisibility() == View.VISIBLE) { holder.playButton.setVisibility(View.GONE); } } else { if (holder.picUrl.contains("youtube")) { if (holder.playButton.getVisibility() == View.GONE) { holder.playButton.setVisibility(View.VISIBLE); } final String fRetweeter = retweeter; holder.image.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String link; boolean displayPic = !holder.picUrl.equals("") && !holder.picUrl.contains("youtube"); if (displayPic) { link = holder.picUrl; } else { link = otherUrl.split(" ")[0]; } Intent viewTweet = new Intent(context, TweetPager.class); viewTweet.putExtra("name", name); viewTweet.putExtra("screenname", screenname); viewTweet.putExtra("time", time); viewTweet.putExtra("tweet", tweetText); viewTweet.putExtra("retweeter", fRetweeter); viewTweet.putExtra("webpage", link); viewTweet.putExtra("other_links", otherUrl); viewTweet.putExtra("picture", displayPic); viewTweet.putExtra("tweetid", holder.tweetId); viewTweet.putExtra("proPic", profilePic); viewTweet.putExtra("users", users); viewTweet.putExtra("hashtags", hashtags); viewTweet.putExtra("clicked_youtube", true); context.startActivity(viewTweet); } }); holder.image.setImageDrawable(transparent); picture = true; } else { holder.image.setImageDrawable(transparent); picture = true; if (holder.playButton.getVisibility() == View.VISIBLE) { holder.playButton.setVisibility(View.GONE); } holder.image.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (holder.picUrl.contains(" ")) { context.startActivity(new Intent(context, ViewPictures.class).putExtra("pictures", holder.picUrl)); } else { context.startActivity(new Intent(context, PhotoViewerDialog.class).putExtra("url", holder.picUrl)); } } }); } if (holder.image.getVisibility() == View.GONE) { holder.image.setVisibility(View.VISIBLE); } } } if (type == NORMAL) { if (retweeter.length() > 0) { holder.retweeter.setText(context.getResources().getString(R.string.retweeter) + retweeter); holder.retweeterName = retweeter; holder.retweeter.setVisibility(View.VISIBLE); } else if (holder.retweeter.getVisibility() == View.VISIBLE) { holder.retweeter.setVisibility(View.GONE); } } else if (type == RETWEET) { int count = status.getRetweetCount(); if (count > 1) { holder.retweeter.setText( status.getRetweetCount() + " " + context.getResources().getString(R.string.retweets_lower)); holder.retweeter.setVisibility(View.VISIBLE); } else if (count == 1) { holder.retweeter.setText( status.getRetweetCount() + " " + context.getResources().getString(R.string.retweet_lower)); holder.retweeter.setVisibility(View.VISIBLE); } } if (picture) { CacheableBitmapDrawable wrapper = mCache.getFromMemoryCache(holder.picUrl); if (wrapper != null) { holder.image.setImageDrawable(wrapper); picture = false; } } final boolean hasPicture = picture; mHandler[currHandler].removeCallbacksAndMessages(null); mHandler[currHandler].postDelayed(new Runnable() { @Override public void run() { if (holder.tweetId == id) { if (hasPicture) { loadImage(context, holder, holder.picUrl, mCache, id); } if (settings.useEmoji && (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT || EmojiUtils.ios)) { String text = holder.tweet.getText().toString(); if (EmojiUtils.emojiPattern.matcher(text).find()) { final Spannable span = EmojiUtils.getSmiledText(context, Html.fromHtml(tweetText)); holder.tweet.setText(span); } } holder.tweet.setSoundEffectsEnabled(false); holder.tweet.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!TouchableMovementMethod.touched) { Log.v("talon_clickable", "clicked in the cursor adapter"); // we need to manually set the background for click feedback because the spannable // absorbs the click on the background if (!holder.preventNextClick) { holder.background.getBackground() .setState(new int[] { android.R.attr.state_pressed }); new Handler().postDelayed(new Runnable() { @Override public void run() { holder.background.getBackground() .setState(new int[] { android.R.attr.state_empty }); } }, 25); } holder.background.performClick(); } } }); holder.tweet.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { if (!TouchableMovementMethod.touched) { holder.background.performLongClick(); holder.preventNextClick = true; } return false; } }); if (holder.retweeter.getVisibility() == View.VISIBLE) { holder.retweeter.setSoundEffectsEnabled(false); holder.retweeter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!TouchableMovementMethod.touched) { if (!holder.preventNextClick) { holder.background.getBackground() .setState(new int[] { android.R.attr.state_pressed }); new Handler().postDelayed(new Runnable() { @Override public void run() { holder.background.getBackground() .setState(new int[] { android.R.attr.state_empty }); } }, 25); } holder.background.performClick(); } } }); holder.retweeter.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { if (!TouchableMovementMethod.touched) { holder.background.performLongClick(); holder.preventNextClick = true; } return false; } }); } TextUtils.linkifyText(context, holder.tweet, holder.background, true, otherUrl, false); TextUtils.linkifyText(context, holder.retweeter, holder.background, true, "", false); } } }, 400); currHandler++; if (currHandler == 10) { currHandler = 0; } if (openFirst && position == 0) { holder.background.performClick(); } }
From source file:com.klinker.android.twitter.data.sq_lite.InteractionsDataSource.java
License:Apache License
public synchronized void createInteraction(Context context, User source, Status status, int account, int type) { ContentValues values = new ContentValues(); long id;// ww w . jav a 2 s .com if (status != null) { id = status.getId(); } else { id = 0; // 0 will be used for whenever it is just a follow } long time = new GregorianCalendar().getTime().getTime(); // current time String users = "@" + source.getScreenName() + " "; String text = ""; String title = ""; switch (type) { case TYPE_FAVORITE: title = "<b>@" + source.getScreenName() + "</b> " + context.getResources().getString(R.string.favorited); text = status.getText(); break; case TYPE_RETWEET: title = "<b>@" + source.getScreenName() + "</b> " + context.getResources().getString(R.string.retweeted); text = status.getRetweetedStatus().getText(); break; case TYPE_FOLLOWER: title = "<b>@" + source.getScreenName() + "</b> " + context.getResources().getString(R.string.followed); break; } values.put(InteractionsSQLiteHelper.COLUMN_ACCOUNT, account); values.put(InteractionsSQLiteHelper.COLUMN_TEXT, text); values.put(InteractionsSQLiteHelper.COLUMN_TWEET_ID, id); values.put(InteractionsSQLiteHelper.COLUMN_PRO_PIC, source.getOriginalProfileImageURL()); values.put(InteractionsSQLiteHelper.COLUMN_TIME, time); values.put(InteractionsSQLiteHelper.COLUMN_UNREAD, 1); values.put(InteractionsSQLiteHelper.COLUMN_USERS, users); values.put(InteractionsSQLiteHelper.COLUMN_TYPE, type); values.put(InteractionsSQLiteHelper.COLUMN_TITLE, title); try { database.insert(InteractionsSQLiteHelper.TABLE_INTERACTIONS, null, values); } catch (Exception e) { open(); database.insert(InteractionsSQLiteHelper.TABLE_INTERACTIONS, null, values); } }
From source file:com.klinker.android.twitter.utils.TweetLinkUtils.java
License:Apache License
public static String[] getLinksInStatus(Status status) { UserMentionEntity[] users = status.getUserMentionEntities(); String mUsers = ""; for (UserMentionEntity name : users) { String n = name.getScreenName(); if (n.length() > 1) { mUsers += n + " "; }/*from w ww . j a v a 2 s. c o m*/ } HashtagEntity[] hashtags = status.getHashtagEntities(); String mHashtags = ""; for (HashtagEntity hashtagEntity : hashtags) { String text = hashtagEntity.getText(); if (text.length() > 1) { mHashtags += text + " "; } } URLEntity[] urls = status.getURLEntities(); String expandedUrls = ""; String compressedUrls = ""; for (URLEntity entity : urls) { String url = entity.getExpandedURL(); if (url.length() > 1) { expandedUrls += url + " "; compressedUrls += entity.getURL() + " "; } } MediaEntity[] medias = status.getMediaEntities(); String mediaExp = ""; String mediaComp = ""; String mediaDisplay = ""; for (MediaEntity e : medias) { String url = e.getURL(); if (url.length() > 1) { mediaComp += url + " "; mediaExp += e.getExpandedURL() + " "; mediaDisplay += e.getDisplayURL() + " "; } } String[] sExpandedUrls; String[] sCompressedUrls; String[] sMediaExp; String[] sMediaComp; String[] sMediaDisplay; try { sCompressedUrls = compressedUrls.split(" "); } catch (Exception e) { sCompressedUrls = new String[0]; } try { sExpandedUrls = expandedUrls.split(" "); } catch (Exception e) { sExpandedUrls = new String[0]; } try { sMediaComp = mediaComp.split(" "); } catch (Exception e) { sMediaComp = new String[0]; } try { sMediaExp = mediaExp.split(" "); } catch (Exception e) { sMediaExp = new String[0]; } try { sMediaDisplay = mediaDisplay.split(" "); } catch (Exception e) { sMediaDisplay = new String[0]; } String tweetTexts = status.getText(); String imageUrl = ""; String otherUrl = ""; for (int i = 0; i < sCompressedUrls.length; i++) { String comp = sCompressedUrls[i]; String exp = sExpandedUrls[i]; if (comp.length() > 1 && exp.length() > 1) { String str = exp.toLowerCase(); try { tweetTexts = tweetTexts.replace(comp, exp.replace("http://", "").replace("https://", "").replace("www.", "").substring(0, 30) + "..."); } catch (Exception e) { tweetTexts = tweetTexts.replace(comp, exp.replace("http://", "").replace("https://", "").replace("www.", "")); } if (str.contains("instag") && !str.contains("blog.insta")) { imageUrl = exp + "media/?size=m"; otherUrl += exp + " "; } else if (exp.toLowerCase().contains("youtub") && !(str.contains("channel") || str.contains("user"))) { // first get the youtube video code int start = exp.indexOf("v=") + 2; int end = exp.length(); if (exp.substring(start).contains("&")) { end = exp.indexOf("&"); } else if (exp.substring(start).contains("?")) { end = exp.indexOf("?"); } try { imageUrl = "http://img.youtube.com/vi/" + exp.substring(start, end) + "/hqdefault.jpg"; } catch (Exception e) { imageUrl = "http://img.youtube.com/vi/" + exp.substring(start, exp.length() - 1) + "/hqdefault.jpg"; } otherUrl += exp + " "; } else if (str.contains("youtu.be")) { // first get the youtube video code int start = exp.indexOf(".be/") + 4; int end = exp.length(); if (exp.substring(start).contains("&")) { end = exp.indexOf("&"); } else if (exp.substring(start).contains("?")) { end = exp.indexOf("?"); } try { imageUrl = "http://img.youtube.com/vi/" + exp.substring(start, end) + "/hqdefault.jpg"; } catch (Exception e) { imageUrl = "http://img.youtube.com/vi/" + exp.substring(start, exp.length() - 1) + "/mqefault.jpg"; } otherUrl += exp + " "; } else if (str.contains("twitpic")) { int start = exp.indexOf(".com/") + 5; imageUrl = "http://twitpic.com/show/full/" + exp.substring(start).replace("/", ""); otherUrl += exp + " "; } else if (str.contains("i.imgur") && !str.contains("/a/")) { int start = exp.indexOf(".com/") + 5; imageUrl = "http://i.imgur.com/" + exp.replace("http://i.imgur.com/", "").replace(".jpg", "") + "m.jpg"; imageUrl = imageUrl.replace("gallery/", ""); otherUrl += exp + " "; } else if (str.contains("imgur") && !str.contains("/a/")) { int start = exp.indexOf(".com/") + 6; imageUrl = "http://i.imgur.com/" + exp.replace("http://imgur.com/", "").replace(".jpg", "") + "m.jpg"; imageUrl = imageUrl.replace("gallery/", "").replace("a/", ""); otherUrl += exp + " "; } else if (str.contains("pbs.twimg.com")) { imageUrl = exp; otherUrl += exp + " "; } else if (str.contains("ow.ly/i")) { imageUrl = "http://static.ow.ly/photos/original/" + exp.substring(exp.lastIndexOf("/")).replaceAll("/", "") + ".jpg"; otherUrl += exp + " "; } else if (str.contains("p.twipple.jp")) { imageUrl = "http://p.twipple.jp/show/large/" + exp.replace("p.twipple.jp/", "") .replace("http://", "").replace("https://", "").replace("www.", ""); otherUrl += exp + " "; } else if (str.contains(".jpg") || str.contains(".png")) { imageUrl = exp; otherUrl += exp + " "; } else { otherUrl += exp + " "; } } } for (int i = 0; i < sMediaComp.length; i++) { String comp = sMediaComp[i]; String exp = sMediaExp[i]; if (comp.length() > 1 && exp.length() > 1) { try { tweetTexts = tweetTexts.replace(comp, sMediaDisplay[i].replace("http://", "") .replace("https://", "").replace("www.", "").substring(0, 22) + "..."); } catch (Exception e) { tweetTexts = tweetTexts.replace(comp, sMediaDisplay[i].replace("http://", "").replace("https://", "").replace("www.", "")); } imageUrl = status.getMediaEntities()[0].getMediaURL(); for (MediaEntity m : status.getExtendedMediaEntities()) { if (m.getType().equals("photo")) { if (!imageUrl.contains(m.getMediaURL())) { imageUrl += " " + m.getMediaURL(); } } } otherUrl += sMediaDisplay[i]; } } return new String[] { tweetTexts, imageUrl, otherUrl, mHashtags, mUsers }; }
From source file:com.krossovochkin.kwitter.adapters.TimelineAdapter.java
License:Apache License
@Override public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { ViewHolder holder = (ViewHolder) viewHolder; Status status = mData.get(position); holder.setText(status.getText()); holder.setImage(status.getUser().getBiggerProfileImageURLHttps()); holder.setUserName(status.getUser().getScreenName()); holder.setText(mData.get(position).getText()); holder.initButtons(mListener, position); }
From source file:com.lambda.stack.KeywordMapper.java
@Override public Iterable<Tuple3<Status, Integer, Integer>> call(Status t) throws Exception { List<Object[]> keywords = null; DatabaseHelper dh = null;// w w w.j a v a 2 s . co m try { dh = DatabaseHelper.openDB(); keywords = dh.listKeywords(); } catch (SQLException e) { e.printStackTrace(); } finally { if (dh != null) dh.close(); } Iterator<Object[]> keyIter = keywords.iterator(); while (keyIter.hasNext()) { Object[] o = keyIter.next(); if (!t.getText().contains((String) o[0])) { keyIter.remove(); } } List<Tuple3<Status, Integer, Integer>> list = new ArrayList<>(); for (Object[] o : keywords) { list.add(new Tuple3<>(t, (Integer) o[1], (Integer) o[2])); } return list; }
From source file:com.lbarriosh.sentimentanalyzer.main.Main.java
License:Open Source License
private static void printTweets(List<Status> tweets) { for (Status tweet : tweets) { System.out.println("@" + tweet.getUser().getName() + ": " + tweet.getText()); }//from ww w . j ava2 s . co m }
From source file:com.lbarriosh.sentimentanalyzer.SentimentAnalyzer.java
License:Open Source License
public DocumentClassifier<Status> generateStatistics(String[] query, int maxResults, TwitterLocale locale, double neutralEpsilon) { try {//from w w w .j ava 2s.c o m TweetsDownloader downloader = new TweetsDownloader(API_KEY, API_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); List<Status> retrievedTweets = downloader.downloadTweets(query, locale, maxResults); TwitterStopWordsDetector sw_detector = StopWordsDetectorFactory.buildStopWordsDetector(locale); sw_detector.loadStopWordsFile(); Lexicon lexicon = LexiconFactory.buildLexicon(locale); lexicon.loadData(); DocumentClassifier<Status> docClassifier = new DocumentClassifier<Status>(neutralEpsilon); docClassifier.resetAllCounters(); for (Status tweet : retrievedTweets) { StringTokenizer tok = new StringTokenizer(tweet.getText(), " "); docClassifier.resetWeightCounters(); while (tok.hasMoreTokens()) { String preProcessedWord = sw_detector.processToken(tok.nextToken()); if (preProcessedWord != null) { LemmaValoration valoration = lexicon.getWordValoration(preProcessedWord); docClassifier.processWordValoration(valoration); } // if } // while docClassifier.classifyDocument(tweet); } // for return docClassifier; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:com.learnncode.twitter.TweetViewHolder.java
License:Apache License
public void populateView(final Context context, final Status status) { mContext = context;//from w ww . j a va2 s . c o m if (status.getUser().getId() != AppSettings.getTwitterUserId(mContext)) { retweetTextView.setEnabled(true); } else { retweetTextView.setEnabled(false); } retweetTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.retweet_action_selector, 0); aQuery = new AQuery(mContext); aQuery.id(userProfileImageView).image(status.getUser().getBiggerProfileImageURL(), true, true, userProfileImageView.getWidth(), 0, null, 0); userNameTextView.setText(status.getUser().getName()); twitterHandlerTextView.setText("@" + status.getUser().getScreenName()); setMessage(mContext, tweetTextView, status.getText()); favoriteTextView.setText(" " + status.getFavoriteCount()); retweetTextView.setText(" " + status.getRetweetCount()); timeTextView.setText(AppUtilities.getConvertDate(status.getCreatedAt().toString())); twitter4j.MediaEntity[] entity = status.getMediaEntities(); int count = entity.length; if (count > 0) { imageContainer.setVisibility(View.VISIBLE); imageWithTweet.setVisibility(View.VISIBLE); for (int i = 0; i < count; i++) { mImageLink = entity[i].getMediaURL(); aQuery.id(imageWithTweet).image(entity[i].getMediaURL(), true, true, userProfileImageView.getWidth(), 0, null, 0); } } else { imageContainer.setVisibility(View.GONE); imageWithTweet.setVisibility(View.GONE); } imageWithTweet.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(context, UIImagePreview.class); intent.putExtra("url", mImageLink); context.startActivity(intent); } }); }
From source file:com.lorenzobraghetto.speakbird.View.MentionsAdapter.java
License:Open Source License
public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder;/*from w ww . j av a 2 s . c o m*/ if (convertView == null) { holder = new ViewHolder(); convertView = inflater.inflate(R.layout.mentionslist, null); holder.imgViewLogo = (ImageView) convertView.findViewById(R.id.personImage); holder.txtViewNick = (TextView) convertView.findViewById(R.id.personName); holder.txtViewText = (TextView) convertView.findViewById(R.id.testo); holder.txtViewTime = (TextView) convertView.findViewById(R.id.time); holder.background = (RelativeLayout) convertView.findViewById(R.id.layout); convertView.setTag(holder); } else holder = (ViewHolder) convertView.getTag(); long d; String urlimg; String nick; String text; if (type.compareTo("mentions") == 0) { Status bean = (Status) itemList.get(position); d = bean.getCreatedAt().getTime(); urlimg = bean.getUser().getProfileImageURL() + ""; nick = bean.getUser().getScreenName(); text = bean.getText(); } else { DirectMessage bean = (DirectMessage) itemList.get(position); d = bean.getCreatedAt().getTime(); urlimg = bean.getSender().getProfileImageURL() + ""; nick = bean.getSender().getScreenName(); text = bean.getText(); } long now = System.currentTimeMillis(); long elapsed = now - d; int minutes = (int) ((elapsed / (1000 * 60)) % 60); int hours = (int) ((elapsed / (1000 * 60 * 60)) % 24); int days = (int) ((elapsed / (1000 * 60 * 60 * 24))); UrlImageViewHelper.setUrlDrawable(holder.imgViewLogo, urlimg); holder.txtViewNick.setText("@" + nick); holder.txtViewText.setText(text); if (days > 0 && hours > 0 && minutes > 0) holder.txtViewTime.setText(days + "d " + hours + "h " + minutes + "m "); else if (hours > 0 && minutes > 0) holder.txtViewTime.setText(hours + "h " + minutes + "m "); else holder.txtViewTime.setText(minutes + "m "); if (position == itemColored) { holder.background.setBackgroundColor(0xffa4a4a4); } else if (first == d) { holder.background .setBackgroundDrawable(context.getResources().getDrawable(R.drawable.sfondotweetunonove)); } else { holder.background.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.sfondotweetnove)); } return convertView; }
From source file:com.marklogic.tweetdeck.LoadRawJSON.java
License:Apache License
/** * Usage: java twitter4j.examples.json.LoadRawJSON * * @param args String[]/* w w w. j a va2 s. co m*/ */ public static void main(String[] args) { try { File[] files = new File("statuses").listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".json"); } }); for (File file : files) { String rawJSON = readFirstLine(file); Status status = TwitterObjectFactory.createStatus(rawJSON); System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText()); } System.exit(0); } catch (IOException ioe) { ioe.printStackTrace(); System.out.println("Failed to store tweets: " + ioe.getMessage()); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get timeline: " + te.getMessage()); System.exit(-1); } }