List of usage examples for twitter4j Status getSource
String getSource();
From source file:com.daiv.android.twitter.data.sq_lite.HomeContentProvider.java
License:Apache License
public static void insertTweet(Status status, int currentAccount, Context context) { ContentValues values = new ContentValues(); String originalName = ""; long id = status.getId(); long time = status.getCreatedAt().getTime(); if (status.isRetweet()) { originalName = status.getUser().getScreenName(); status = status.getRetweetedStatus(); }//w w w. j a v a 2s. c o m String[] html = TweetLinkUtils.getLinksInStatus(status); String text = html[0]; String media = html[1]; String url = html[2]; String hashtags = html[3]; String users = html[4]; String source; if (status.isRetweet()) { source = android.text.Html.fromHtml(status.getRetweetedStatus().getSource()).toString(); } else { source = android.text.Html.fromHtml(status.getSource()).toString(); } values.put(HomeSQLiteHelper.COLUMN_ACCOUNT, currentAccount); values.put(HomeSQLiteHelper.COLUMN_TEXT, text); values.put(HomeSQLiteHelper.COLUMN_TWEET_ID, id); values.put(HomeSQLiteHelper.COLUMN_NAME, status.getUser().getName()); values.put(HomeSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL()); values.put(HomeSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName()); values.put(HomeSQLiteHelper.COLUMN_TIME, time); values.put(HomeSQLiteHelper.COLUMN_RETWEETER, originalName); values.put(HomeSQLiteHelper.COLUMN_UNREAD, 1); values.put(HomeSQLiteHelper.COLUMN_PIC_URL, media); values.put(HomeSQLiteHelper.COLUMN_URL, url); values.put(HomeSQLiteHelper.COLUMN_USERS, users); values.put(HomeSQLiteHelper.COLUMN_HASHTAGS, hashtags); values.put(HomeSQLiteHelper.COLUMN_CLIENT_SOURCE, source); context.getContentResolver().insert(HomeContentProvider.CONTENT_URI, values); }
From source file:com.daiv.android.twitter.data.sq_lite.HomeContentProvider.java
License:Apache License
public static int insertTweets(List<Status> statuses, int currentAccount, Context context) { ContentValues[] valueses = new ContentValues[statuses.size()]; for (int i = 0; i < statuses.size(); i++) { Status status = statuses.get(i); ContentValues values = new ContentValues(); String originalName = ""; long mId = status.getId(); long time = status.getCreatedAt().getTime(); if (status.isRetweet()) { originalName = status.getUser().getScreenName(); status = status.getRetweetedStatus(); }/*from w w w .ja v a 2s.c o m*/ String[] html = TweetLinkUtils.getLinksInStatus(status); String text = html[0]; String media = html[1]; String url = html[2]; String hashtags = html[3]; String users = html[4]; String source; if (status.isRetweet()) { source = android.text.Html.fromHtml(status.getRetweetedStatus().getSource()).toString(); } else { source = android.text.Html.fromHtml(status.getSource()).toString(); } values.put(HomeSQLiteHelper.COLUMN_ACCOUNT, currentAccount); values.put(HomeSQLiteHelper.COLUMN_TEXT, text); values.put(HomeSQLiteHelper.COLUMN_TWEET_ID, mId); values.put(HomeSQLiteHelper.COLUMN_NAME, status.getUser().getName()); values.put(HomeSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL()); values.put(HomeSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName()); values.put(HomeSQLiteHelper.COLUMN_TIME, time); values.put(HomeSQLiteHelper.COLUMN_RETWEETER, originalName); values.put(HomeSQLiteHelper.COLUMN_UNREAD, 1); values.put(HomeSQLiteHelper.COLUMN_PIC_URL, media); values.put(HomeSQLiteHelper.COLUMN_URL, url); values.put(HomeSQLiteHelper.COLUMN_USERS, users); values.put(HomeSQLiteHelper.COLUMN_HASHTAGS, hashtags); values.put(HomeSQLiteHelper.COLUMN_CLIENT_SOURCE, source); valueses[i] = values; } return context.getContentResolver().bulkInsert(HomeContentProvider.CONTENT_URI, valueses); }
From source file:com.daiv.android.twitter.data.sq_lite.HomeDataSource.java
License:Apache License
public synchronized void createTweet(Status status, int account) { ContentValues values = new ContentValues(); String originalName = ""; long time = status.getCreatedAt().getTime(); long id = status.getId(); if (status.isRetweet()) { originalName = status.getUser().getScreenName(); status = status.getRetweetedStatus(); }/* ww w . ja v a2 s .c o m*/ String[] html = TweetLinkUtils.getLinksInStatus(status); String text = html[0]; String media = html[1]; String url = html[2]; String hashtags = html[3]; String users = html[4]; String source; if (status.isRetweet()) { source = android.text.Html.fromHtml(status.getRetweetedStatus().getSource()).toString(); } else { source = android.text.Html.fromHtml(status.getSource()).toString(); } if (media.contains("/tweet_video/")) { media = media.replace("tweet_video", "tweet_video_thumb").replace(".mp4", ".png"); } values.put(HomeSQLiteHelper.COLUMN_ACCOUNT, account); values.put(HomeSQLiteHelper.COLUMN_TEXT, text); values.put(HomeSQLiteHelper.COLUMN_TWEET_ID, id); values.put(HomeSQLiteHelper.COLUMN_NAME, status.getUser().getName()); values.put(HomeSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL()); values.put(HomeSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName()); values.put(HomeSQLiteHelper.COLUMN_TIME, time); values.put(HomeSQLiteHelper.COLUMN_RETWEETER, originalName); values.put(HomeSQLiteHelper.COLUMN_UNREAD, 1); values.put(HomeSQLiteHelper.COLUMN_PIC_URL, media); values.put(HomeSQLiteHelper.COLUMN_URL, url); values.put(HomeSQLiteHelper.COLUMN_USERS, users); values.put(HomeSQLiteHelper.COLUMN_HASHTAGS, hashtags); values.put(HomeSQLiteHelper.COLUMN_CLIENT_SOURCE, source); values.put(HomeSQLiteHelper.COLUMN_ANIMATED_GIF, TweetLinkUtils.getGIFUrl(status, url)); values.put(HomeSQLiteHelper.COLUMN_CONVERSATION, status.getInReplyToStatusId() == -1 ? 0 : 1); try { database.insert(HomeSQLiteHelper.TABLE_HOME, null, values); } catch (Exception e) { open(); database.insert(HomeSQLiteHelper.TABLE_HOME, null, values); } }
From source file:com.daiv.android.twitter.data.sq_lite.HomeDataSource.java
License:Apache License
public synchronized void createTweet(Status status, int account, boolean initial) { ContentValues values = new ContentValues(); String originalName = ""; long time = status.getCreatedAt().getTime(); long id = status.getId(); if (status.isRetweet()) { originalName = status.getUser().getScreenName(); status = status.getRetweetedStatus(); }//from w ww . j a va 2 s . c o m String[] html = TweetLinkUtils.getLinksInStatus(status); String text = html[0]; String media = html[1]; String url = html[2]; String hashtags = html[3]; String users = html[4]; String source; if (status.isRetweet()) { source = android.text.Html.fromHtml(status.getRetweetedStatus().getSource()).toString(); } else { source = android.text.Html.fromHtml(status.getSource()).toString(); } if (media.contains("/tweet_video/")) { media = media.replace("tweet_video", "tweet_video_thumb").replace(".mp4", ".png"); } values.put(HomeSQLiteHelper.COLUMN_ACCOUNT, account); values.put(HomeSQLiteHelper.COLUMN_TEXT, text); values.put(HomeSQLiteHelper.COLUMN_TWEET_ID, id); values.put(HomeSQLiteHelper.COLUMN_NAME, status.getUser().getName()); values.put(HomeSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL()); values.put(HomeSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName()); values.put(HomeSQLiteHelper.COLUMN_TIME, time); values.put(HomeSQLiteHelper.COLUMN_RETWEETER, originalName); values.put(HomeSQLiteHelper.COLUMN_UNREAD, 0); values.put(HomeSQLiteHelper.COLUMN_PIC_URL, media); values.put(HomeSQLiteHelper.COLUMN_URL, url); values.put(HomeSQLiteHelper.COLUMN_USERS, users); values.put(HomeSQLiteHelper.COLUMN_HASHTAGS, hashtags); values.put(HomeSQLiteHelper.COLUMN_CLIENT_SOURCE, source); values.put(HomeSQLiteHelper.COLUMN_ANIMATED_GIF, TweetLinkUtils.getGIFUrl(status, url)); values.put(HomeSQLiteHelper.COLUMN_CONVERSATION, status.getInReplyToStatusId() == -1 ? 0 : 1); try { database.insert(HomeSQLiteHelper.TABLE_HOME, null, values); } catch (Exception e) { open(); database.insert(HomeSQLiteHelper.TABLE_HOME, null, values); } }
From source file:com.daiv.android.twitter.data.sq_lite.HomeDataSource.java
License:Apache License
public synchronized int insertTweets(List<Status> statuses, int currentAccount, long[] lastIds) { ContentValues[] valueses = new ContentValues[statuses.size()]; for (int i = 0; i < statuses.size(); i++) { Status status = statuses.get(i); Long id = status.getId(); ContentValues values = new ContentValues(); if (id > lastIds[0]) { String originalName = ""; long mId = status.getId(); long time = status.getCreatedAt().getTime(); if (status.isRetweet()) { originalName = status.getUser().getScreenName(); status = status.getRetweetedStatus(); }//from ww w. ja v a 2s . c o m String[] html = TweetLinkUtils.getLinksInStatus(status); String text = html[0]; String media = html[1]; String url = html[2]; String hashtags = html[3]; String users = html[4]; String source; if (status.isRetweet()) { source = android.text.Html.fromHtml(status.getRetweetedStatus().getSource()).toString(); } else { source = android.text.Html.fromHtml(status.getSource()).toString(); } if (media.contains("/tweet_video/")) { media = media.replace("tweet_video", "tweet_video_thumb").replace(".mp4", ".png"); } values.put(HomeSQLiteHelper.COLUMN_ACCOUNT, currentAccount); values.put(HomeSQLiteHelper.COLUMN_TEXT, text); values.put(HomeSQLiteHelper.COLUMN_TWEET_ID, mId); values.put(HomeSQLiteHelper.COLUMN_NAME, status.getUser().getName()); values.put(HomeSQLiteHelper.COLUMN_PRO_PIC, status.getUser().getOriginalProfileImageURL()); values.put(HomeSQLiteHelper.COLUMN_SCREEN_NAME, status.getUser().getScreenName()); values.put(HomeSQLiteHelper.COLUMN_TIME, time); values.put(HomeSQLiteHelper.COLUMN_RETWEETER, originalName); values.put(HomeSQLiteHelper.COLUMN_UNREAD, 1); values.put(HomeSQLiteHelper.COLUMN_PIC_URL, media); values.put(HomeSQLiteHelper.COLUMN_URL, url); values.put(HomeSQLiteHelper.COLUMN_USERS, users); values.put(HomeSQLiteHelper.COLUMN_HASHTAGS, hashtags); values.put(HomeSQLiteHelper.COLUMN_CLIENT_SOURCE, source); values.put(HomeSQLiteHelper.COLUMN_ANIMATED_GIF, TweetLinkUtils.getGIFUrl(status, url)); values.put(HomeSQLiteHelper.COLUMN_CONVERSATION, status.getInReplyToStatusId() == -1 ? 0 : 1); } else { values = null; } valueses[i] = values; } ArrayList<ContentValues> vals = new ArrayList<ContentValues>(); for (ContentValues v : valueses) { if (v != null) { vals.add(v); } } insertMultiple(valueses); return vals.size(); }
From source file:com.daiv.android.twitter.ui.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//from w w w.j a va 2 s . co m 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() { // you can't retweet a protected account if (status.getUser().isProtected()) { retweetButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(context, getString(R.string.protected_account), Toast.LENGTH_SHORT).show(); } }); } 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("Test_image", s); } } }); } catch (Exception e) { } } }); getInfo.setPriority(Thread.MAX_PRIORITY); getInfo.start(); }
From source file:com.dhamacher.tweetsentimentanalysis.Main.java
License:Open Source License
private static void persistTweet(QueryResult result, String token) { EntityTransaction tx = em.getTransaction(); tx.begin();//from w w w .ja v a 2 s . co m for (Status status : result.getTweets()) { Tweet entity = new Tweet(); entity.setTweetId(status.getId()); entity.setSearchToken(token); entity.setCreatedOn(status.getCreatedAt()); entity.setIsRetweet(status.isRetweet()); entity.setSource(status.getSource()); entity.setUser(status.getUser()); entity.setText(status.getText()); em.persist(entity); } tx.commit(); }
From source file:com.dwdesign.tweetings.model.ParcelableStatus.java
License:Open Source License
public ParcelableStatus(Status status, final long account_id, final boolean is_gap, final boolean large_inline_image_preview) { this.is_gap = is_gap; this.account_id = account_id; status_id = status.getId();/* ww w. j a va 2 s. co m*/ is_retweet = status.isRetweet(); final Status retweeted_status = is_retweet ? status.getRetweetedStatus() : null; final User retweet_user = retweeted_status != null ? status.getUser() : null; retweet_id = retweeted_status != null ? retweeted_status.getId() : -1; retweeted_by_id = retweet_user != null ? retweet_user.getId() : -1; retweeted_by_name = retweet_user != null ? retweet_user.getName() : null; retweeted_by_screen_name = retweet_user != null ? retweet_user.getScreenName() : null; if (retweeted_status != null) { status = retweeted_status; } final User user = status.getUser(); user_id = user != null ? user.getId() : -1; name = user != null ? user.getName() : null; screen_name = user != null ? user.getScreenName() : null; profile_image_url = user != null ? user.getProfileImageURL() : null; profile_image_url_string = profile_image_url != null ? profile_image_url.toString() : null; is_protected = user != null ? user.isProtected() : false; is_verified = user != null ? user.isVerified() : false; final MediaEntity[] medias = status.getMediaEntities(); status_timestamp = getTime(status.getCreatedAt()); text_html = formatStatusText(status); final PreviewImage preview = getPreviewImage(text_html, large_inline_image_preview ? INLINE_IMAGE_PREVIEW_DISPLAY_OPTION_CODE_LARGE_HIGH : INLINE_IMAGE_PREVIEW_DISPLAY_OPTION_CODE_SMALL); text_plain = status.getText(); retweet_count = status.getRetweetCount(); in_reply_to_screen_name = status.getInReplyToScreenName(); in_reply_to_status_id = status.getInReplyToStatusId(); source = status.getSource(); location = new ParcelableLocation(status.getGeoLocation()); location_string = location.toString(); is_favorite = status.isFavorited(); has_media = medias != null && medias.length > 0 || preview.has_image; text = text_html != null ? Html.fromHtml(text_html) : null; image_preview_url_string = preview.matched_url; image_orig_url_string = preview.orig_url; image_preview_url = parseURL(image_preview_url_string); text_unescaped = unescape(text_html); String play = null; URLEntity[] urls = status.getURLEntities(); if (urls != null) { for (final URLEntity url : urls) { final URL tco_url = url.getURL(); final URL expanded_url = url.getExpandedURL(); if (tco_url != null && expanded_url != null && expanded_url.toString().contains("play.google.com/store/apps")) { play = expanded_url.toString(); break; } } } play_package = play; is_possibly_sensitive = status.isPossiblySensitive(); }
From source file:com.dwdesign.tweetings.util.Utils.java
License:Open Source License
public static ContentValues makeStatusContentValues(Status status, final long account_id) { if (status == null || status.getId() <= 0) return null; final ContentValues values = new ContentValues(); values.put(Statuses.ACCOUNT_ID, account_id); values.put(Statuses.STATUS_ID, status.getId()); final boolean is_retweet = status.isRetweet(); final Status retweeted_status = is_retweet ? status.getRetweetedStatus() : null; if (retweeted_status != null) { final User retweet_user = status.getUser(); values.put(Statuses.RETWEET_ID, retweeted_status.getId()); values.put(Statuses.RETWEETED_BY_ID, retweet_user.getId()); values.put(Statuses.RETWEETED_BY_NAME, retweet_user.getName()); values.put(Statuses.RETWEETED_BY_SCREEN_NAME, retweet_user.getScreenName()); status = retweeted_status;//from w w w . j a va2s . c o m } final User user = status.getUser(); if (user != null) { final long user_id = user.getId(); final String profile_image_url = user.getProfileImageURL().toString(); final String name = user.getName(), screen_name = user.getScreenName(); values.put(Statuses.USER_ID, user_id); values.put(Statuses.NAME, name); values.put(Statuses.SCREEN_NAME, screen_name); values.put(Statuses.IS_PROTECTED, user.isProtected() ? 1 : 0); values.put(Statuses.IS_VERIFIED, user.isVerified() ? 1 : 0); values.put(Statuses.PROFILE_IMAGE_URL, profile_image_url); } if (status.getCreatedAt() != null) { values.put(Statuses.STATUS_TIMESTAMP, status.getCreatedAt().getTime()); } values.put(Statuses.TEXT, formatStatusText(status)); values.put(Statuses.TEXT_PLAIN, status.getText()); values.put(Statuses.RETWEET_COUNT, status.getRetweetCount()); values.put(Statuses.IN_REPLY_TO_SCREEN_NAME, status.getInReplyToScreenName()); values.put(Statuses.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId()); values.put(Statuses.SOURCE, status.getSource()); values.put(Statuses.IS_POSSIBLY_SENSITIVE, status.isPossiblySensitive()); final GeoLocation location = status.getGeoLocation(); if (location != null) { values.put(Statuses.LOCATION, location.getLatitude() + "," + location.getLongitude()); } values.put(Statuses.IS_RETWEET, is_retweet ? 1 : 0); values.put(Statuses.IS_FAVORITE, status.isFavorited() ? 1 : 0); return values; }
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 ww. j av a2 s. 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(); }