Example usage for twitter4j Status getFavoriteCount

List of usage examples for twitter4j Status getFavoriteCount

Introduction

In this page you can find the example usage for twitter4j Status getFavoriteCount.

Prototype

int getFavoriteCount();

Source Link

Document

Indicates approximately how many times this Tweet has been "favorited" by Twitter users.

Usage

From source file:com.klinker.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/*w  ww  .jav a2 s. co  m*/
        public void run() {
            String location = "";
            String via = "";
            long realTime = 0;
            boolean retweetedByMe = false;
            try {
                Twitter twitter = Utils.getTwitter(context, settings);

                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("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.learnncode.twitter.TweetViewHolder.java

License:Apache License

public void populateView(final Context context, final Status status) {
    mContext = context;/* w w w .j a  va 2 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.marpies.ane.twitter.utils.StatusUtils.java

License:Apache License

public static JSONObject getJSON(Status status) throws JSONException {
    JSONObject statusJSON = new JSONObject();
    statusJSON.put("id", status.getId());
    statusJSON.put("idStr", String.valueOf(status.getId()));
    statusJSON.put("text", status.getText());
    statusJSON.put("replyToUserID", status.getInReplyToUserId());
    statusJSON.put("replyToStatusID", status.getInReplyToStatusId());
    statusJSON.put("likesCount", status.getFavoriteCount());
    statusJSON.put("retweetCount", status.getRetweetCount());
    statusJSON.put("isRetweet", status.isRetweet());
    statusJSON.put("isSensitive", status.isPossiblySensitive());
    statusJSON.put("createdAt", status.getCreatedAt());
    Status retweetedStatus = status.getRetweetedStatus();
    if (retweetedStatus != null) {
        statusJSON.put("retweetedStatus", getJSON(retweetedStatus));
    }/*from   w  w  w  .ja va  2 s  . c o m*/
    User user = status.getUser();
    if (user != null) {
        statusJSON.put("user", UserUtils.getJSON(user));
    }
    return statusJSON;
}

From source file:com.raythos.sentilexo.twitter.domain.QueryResultItemMapper.java

License:Apache License

public static Map getFieldsMapFromStatus(String queryOwner, String queryName, String queryString,
        Status status) {

    if (queryName != null)
        queryName = queryName.toLowerCase();
    if (queryOwner != null)
        queryOwner = queryOwner.toLowerCase();
    Map m = StatusArraysHelper.getUserMentionMap(status);
    Map newMap = new HashMap();
    for (Object key : m.keySet()) {
        newMap.put(key.toString(), (Long) m.get(key));
    }/*from w  w w . j a v  a 2  s .  c o m*/
    Double longitude = null;
    Double lattitude = null;
    if (status.getGeoLocation() != null) {
        longitude = status.getGeoLocation().getLongitude();
        lattitude = status.getGeoLocation().getLatitude();
    }
    String place = null;
    if (status.getPlace() != null) {
        place = status.getPlace().getFullName();
    }

    boolean isRetweet = status.getRetweetedStatus() != null;
    Long retweetedId = null;
    String retweetedText = null;
    if (isRetweet) {
        retweetedId = status.getRetweetedStatus().getId();
        retweetedText = status.getRetweetedStatus().getText();
    }

    Map<String, Object> result = new HashMap<>();
    result.put(QueryResultItemFieldNames.STATUS_ID, status.getId());
    result.put(QueryResultItemFieldNames.CREATED_AT, status.getCreatedAt());
    result.put(QueryResultItemFieldNames.CURRENT_USER_RETWEET_ID, status.getCurrentUserRetweetId());
    result.put(QueryResultItemFieldNames.FAVOURITE_COUNT, status.getFavoriteCount());
    result.put(QueryResultItemFieldNames.FAVOURITED, status.isFavorited());
    result.put(QueryResultItemFieldNames.HASHTAGS, StatusArraysHelper.getHashTagsList(status));
    result.put(QueryResultItemFieldNames.IN_REPLY_TO_SCREEN_NAME, (status.getInReplyToScreenName()));
    result.put(QueryResultItemFieldNames.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId());
    result.put(QueryResultItemFieldNames.IN_REPLY_TO_USER_ID, status.getInReplyToUserId());
    result.put(QueryResultItemFieldNames.LATITUDE, lattitude);
    result.put(QueryResultItemFieldNames.LONGITUDE, longitude);
    result.put(QueryResultItemFieldNames.MENTIONS, newMap);
    result.put(QueryResultItemFieldNames.LANGUAGE, status.getLang());
    result.put(QueryResultItemFieldNames.PLACE, place);
    result.put(QueryResultItemFieldNames.POSSIBLY_SENSITIVE, status.isPossiblySensitive());
    result.put(QueryResultItemFieldNames.QUERY_NAME, queryName);
    result.put(QueryResultItemFieldNames.QUERY_OWNER, queryOwner);
    result.put(QueryResultItemFieldNames.QUERY, queryString);
    result.put(QueryResultItemFieldNames.RELEVANT_QUERY_TERMS,
            TwitterUtils.relevantQueryTermsFromStatus(queryString, status));
    result.put(QueryResultItemFieldNames.RETWEET, isRetweet);
    result.put(QueryResultItemFieldNames.RETWEET_COUNT, status.getRetweetCount());
    result.put(QueryResultItemFieldNames.RETWEETED, status.isRetweeted());
    result.put(QueryResultItemFieldNames.RETWEETED_BY_ME, status.isRetweetedByMe());
    result.put(QueryResultItemFieldNames.RETWEET_STATUS_ID, retweetedId);
    result.put(QueryResultItemFieldNames.RETWEETED_TEXT, retweetedText);
    result.put(QueryResultItemFieldNames.SCOPES, StatusArraysHelper.getScopesList(status));
    result.put(QueryResultItemFieldNames.SCREEN_NAME, status.getUser().getScreenName());
    result.put(QueryResultItemFieldNames.SOURCE, (status.getSource()));
    result.put(QueryResultItemFieldNames.TEXT, (status.getText()));
    result.put(QueryResultItemFieldNames.TRUNCATED, status.isTruncated());
    result.put(QueryResultItemFieldNames.URLS, StatusArraysHelper.getUrlsList(status));
    result.put(QueryResultItemFieldNames.USER_ID, status.getUser().getId());
    result.put(QueryResultItemFieldNames.USER_NAME, (status.getUser().getName()));
    result.put(QueryResultItemFieldNames.USER_DESCRIPTION, (status.getUser().getDescription()));
    result.put(QueryResultItemFieldNames.USER_LOCATION, (status.getUser().getLocation()));
    result.put(QueryResultItemFieldNames.USER_URL, (status.getUser().getURL()));
    result.put(QueryResultItemFieldNames.USER_IS_PROTECTED, status.getUser().isProtected());
    result.put(QueryResultItemFieldNames.USER_FOLLOWERS_COUNT, status.getUser().getFollowersCount());
    result.put(QueryResultItemFieldNames.USER_CREATED_AT, status.getUser().getCreatedAt());
    result.put(QueryResultItemFieldNames.USER_FRIENDS_COUNT, status.getUser().getFriendsCount());
    result.put(QueryResultItemFieldNames.USER_LISTED_COUNT, status.getUser().getListedCount());
    result.put(QueryResultItemFieldNames.USER_STATUSES_COUNT, status.getUser().getStatusesCount());
    result.put(QueryResultItemFieldNames.USER_FAVOURITES_COUNT, status.getUser().getFavouritesCount());
    return result;
}

From source file:com.raythos.sentilexo.twitter.domain.QueryResultItemMapper.java

License:Apache License

public static TwitterQueryResultItemAvro mapItem(String queryOwner, String queryName, String queryString,
        Status status) {
    TwitterQueryResultItemAvro result = new TwitterQueryResultItemAvro();

    if (queryName != null)
        queryName = queryName.toLowerCase();
    if (queryOwner != null)
        queryOwner = queryOwner.toLowerCase();

    result.setQueryName(queryName);/*  w w w  .  ja va  2s  .  c om*/
    result.setQueryOwner(queryOwner);
    result.setQuery(queryString);
    result.setStatusId(status.getId());
    result.setText(status.getText());

    result.setRelevantQueryTerms(TwitterUtils.relevantQueryTermsFromStatus(queryString, status));
    result.setLang(status.getLang());

    result.setCreatedAt(status.getCreatedAt().getTime());

    User user = status.getUser();
    result.setUserId(user.getId());
    result.setScreenName(user.getScreenName());
    result.setUserLocation(user.getLocation());
    result.setUserName(user.getName());
    result.setUserDescription(user.getDescription());
    result.setUserIsProtected(user.isProtected());
    result.setUserFollowersCount(user.getFollowersCount());
    result.setUserCreatedAt(user.getCreatedAt().getTime());
    result.setUserCreatedAtAsString(DateTimeUtils.getDateAsText(user.getCreatedAt()));
    result.setCreatedAtAsString(DateTimeUtils.getDateAsText(status.getCreatedAt()));
    result.setUserFriendsCount(user.getFriendsCount());
    result.setUserListedCount(user.getListedCount());
    result.setUserStatusesCount(user.getStatusesCount());
    result.setUserFavoritesCount(user.getFavouritesCount());

    result.setCurrentUserRetweetId(status.getCurrentUserRetweetId());

    result.setInReplyToScreenName(status.getInReplyToScreenName());
    result.setInReplyToStatusId(status.getInReplyToStatusId());
    result.setInReplyToUserId(status.getInReplyToUserId());

    if (status.getGeoLocation() != null) {
        result.setLatitude(status.getGeoLocation().getLatitude());
        result.setLongitude(status.getGeoLocation().getLongitude());
    }

    result.setSource(status.getSource());
    result.setTrucated(status.isTruncated());
    result.setPossiblySensitive(status.isPossiblySensitive());

    result.setRetweet(status.getRetweetedStatus() != null);
    if (result.getRetweet()) {
        result.setRetweetStatusId(status.getRetweetedStatus().getId());
        result.setRetweetedText(status.getRetweetedStatus().getText());
    }
    result.setRetweeted(status.isRetweeted());
    result.setRetweetCount(status.getRetweetCount());
    result.setRetweetedByMe(status.isRetweetedByMe());

    result.setFavoriteCount(status.getFavoriteCount());
    result.setFavourited(status.isFavorited());

    if (status.getPlace() != null) {
        result.setPlace(status.getPlace().getFullName());
    }

    Scopes scopesObj = status.getScopes();
    if (scopesObj != null) {
        List scopes = Arrays.asList(scopesObj.getPlaceIds());
        result.setScopes(scopes);
    }
    return result;
}

From source file:com.rowland.hashtrace.utility.Utility.java

License:Apache License

public static Tweet createTweet(Status status) {
    User user = status.getUser();//from  w ww .  j  a  v  a 2 s. co m

    long tweet_id = status.getId();

    String tweet_text = status.getText();

    Date tweet_text_date = status.getCreatedAt();

    int tweet_retweet_count = status.getRetweetCount();

    int tweet_favourite_count = status.getFavoriteCount();

    int tweet_mentions_count = status.getUserMentionEntities().length;

    String user_name = user.getScreenName();

    String user_image_url = user.getBiggerProfileImageURL();

    String user_cover_url = user.getProfileBackgroundImageURL();

    String user_location = user.getLocation();

    String user_description = user.getDescription();

    Tweet tweet = new Tweet(tweet_id, tweet_text, tweet_text_date, tweet_retweet_count, tweet_favourite_count,
            tweet_mentions_count, user_name, user_image_url, user_location, user_description, user_cover_url);

    return tweet;
}

From source file:crawltweets2mongo.MonoThread.java

void getNewTweets(String keyword) {
    try {//from   w  ww .  j a  v  a2 s .  com
        Query query = new Query(keyword);
        query.setCount(20000);
        QueryResult result;
        result = twitter.search(query);

        //System.out.println("Getting Tweets..by Key.");
        List<Status> tweets = result.getTweets();

        for (Status tweet : tweets) {

            BasicDBObject basicObj = new BasicDBObject();
            basicObj.put("user_Rname", tweet.getUser().getName());
            basicObj.put("user_name", tweet.getUser().getScreenName());
            basicObj.put("retweet_count", tweet.getRetweetCount());
            basicObj.put("tweet_followers_count", tweet.getUser().getFollowersCount());

            UserMentionEntity[] mentioned = tweet.getUserMentionEntities();
            basicObj.put("tweet_mentioned_count", mentioned.length);
            basicObj.put("tweet_ID", tweet.getId());
            basicObj.put("tweet_text", tweet.getText());
            Status temp1 = tweet.getRetweetedStatus();
            if (temp1 != null)
                basicObj.put("Re_tweet_ID", temp1.getUser().getId());
            GeoLocation loc = tweet.getGeoLocation();
            if (loc != null) {
                basicObj.put("Latitude", loc.getLatitude());
                basicObj.put("Longitude", loc.getLongitude());
            }
            basicObj.put("CreateTime", tweet.getCreatedAt());
            basicObj.put("FavoriteCount", tweet.getFavoriteCount());
            basicObj.put("user_Id", tweet.getUser().getId());

            if (tweet.getUser().getTimeZone() != null)
                basicObj.put("UsertimeZone", tweet.getUser().getTimeZone());
            if (tweet.getUser().getStatus() != null)
                basicObj.put("UserStatus", tweet.getUser().getStatus());
            //basicObj.put("tweetLocation", tweet.getPlace().getGeometryCoordinates());
            String U_Loc = tweet.getUser().getLocation();
            if (U_Loc != null)
                basicObj.put("userLocation", U_Loc);
            basicObj.put("number_of_rt", tweet.getRetweetCount());

            if (mentioned.length > 0) {
                basicObj.append("mentions", pickMentions(mentioned));
            }
            try {

                collection.insert(basicObj);
            } catch (Exception e) {
                //System.out.println("MongoDB Connection Error : " + e.getMessage());
                //                            loadMenu();
            }
        }
        collection.ensureIndex(new BasicDBObject("tweet_ID", 1), new BasicDBObject("unique", true));
    } catch (TwitterException ex) {
        java.util.logging.Logger.getLogger(MonoThread.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:crawltweets2mongo.MonoThread.java

void getNewTweets(GeoLocation myLoc, double radius) {
    try {/*  w  w  w  . ja va  2s  . co m*/
        Query query = new Query();
        Query.Unit unit = Query.KILOMETERS; // or Query.MILES;
        query.setGeoCode(myLoc, radius, unit);
        if (radius > 200)
            query.setCount(20000);
        else
            query.setCount(20000);

        QueryResult result;
        result = this.twitter.search(query);

        //System.out.println("Getting Tweets. by Geo..");
        List<Status> tweets = result.getTweets();

        for (Status tweet : tweets) {

            BasicDBObject basicObj = new BasicDBObject();
            basicObj.put("user_Rname", tweet.getUser().getName());
            basicObj.put("user_name", tweet.getUser().getScreenName());
            basicObj.put("retweet_count", tweet.getRetweetCount());
            basicObj.put("tweet_followers_count", tweet.getUser().getFollowersCount());

            UserMentionEntity[] mentioned = tweet.getUserMentionEntities();
            basicObj.put("tweet_mentioned_count", mentioned.length);
            basicObj.put("tweet_ID", tweet.getId());
            basicObj.put("tweet_text", tweet.getText());
            Status temp1 = tweet.getRetweetedStatus();
            if (temp1 != null)
                basicObj.put("Re_tweet_ID", temp1.getUser().getId());
            GeoLocation loc = tweet.getGeoLocation();
            if (loc != null) {
                basicObj.put("Latitude", loc.getLatitude());
                basicObj.put("Longitude", loc.getLongitude());
            }
            basicObj.put("CreateTime", tweet.getCreatedAt());
            basicObj.put("FavoriteCount", tweet.getFavoriteCount());
            basicObj.put("user_Id", tweet.getUser().getId());

            if (tweet.getUser().getTimeZone() != null)
                basicObj.put("UsertimeZone", tweet.getUser().getTimeZone());
            if (tweet.getUser().getStatus() != null)
                basicObj.put("UserStatus", tweet.getUser().getStatus());
            //basicObj.put("tweetLocation", tweet.getPlace().getGeometryCoordinates());
            String U_Loc = tweet.getUser().getLocation();
            if (U_Loc != null)
                basicObj.put("userLocation", U_Loc);
            basicObj.put("number_of_rt", tweet.getRetweetCount());
            //basicObj.put("isRetweet", tweet.getPlace().getGeometryCoordinates());                
            //basicObj.put("POS", tweet.getWithheldInCountries());

            if (mentioned.length > 0) {
                basicObj.append("mentions", pickMentions(mentioned));
            }
            try {
                //items.insert(basicObj);
                collection.insert(basicObj);
            } catch (Exception e) {
                //     System.out.println("MongoDB Connection Error : " + e.getMessage());
                //                            loadMenu();
            }
        }
        collection.ensureIndex(new BasicDBObject("tweet_ID", 1), new BasicDBObject("unique", true));
    } catch (TwitterException ex) {
        java.util.logging.Logger.getLogger(MonoThread.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:DataCollections.TweetHelper.java

public Tweet_dbo convertStatusToTweet_dbo(Status s) {
    Tweet_dbo tweet = new Tweet_dbo();
    tweet.values[Tweet_dbo.map.get("tweet_id")].setValue(String.valueOf(s.getId()));
    tweet.values[Tweet_dbo.map.get("user_id")].setValue(String.valueOf(s.getUser().getId()));
    tweet.values[Tweet_dbo.map.get("user_screenname")]
            .setValue(removeEscapeCharacters(s.getUser().getScreenName()));
    if (s.getGeoLocation() != null) {
        tweet.values[Tweet_dbo.map.get("lon")].setValue(String.valueOf(s.getGeoLocation().getLongitude()));
        tweet.values[Tweet_dbo.map.get("lat")].setValue(String.valueOf(s.getGeoLocation().getLatitude()));
    }/* w w w .j  a  va 2s .c  om*/
    //tweet.values[Tweet_dbo.map.get("f_search")].setValue("true");
    tweet.values[Tweet_dbo.map.get("text")].setValue(removeEscapeCharacters(s.getText()));
    tweet.values[Tweet_dbo.map.get("hashtags")].setValue(stringifyHashtags(s.getHashtagEntities()));
    tweet.values[Tweet_dbo.map.get("mentions")].setValue(stringiyMentions(s.getUserMentionEntities()));
    tweet.values[Tweet_dbo.map.get("favouritecount")].setValue(String.valueOf(s.getFavoriteCount()));
    tweet.values[Tweet_dbo.map.get("retweetcount")].setValue(String.valueOf(s.getRetweetCount()));
    return tweet;
}

From source file:de.vanita5.twittnuker.model.ParcelableStatus.java

License:Open Source License

public ParcelableStatus(final Status orig, final long account_id, final boolean is_gap) {
    this.is_gap = is_gap;
    this.account_id = account_id;
    id = orig.getId();/*from w w  w  . j av a  2  s .  c o  m*/
    timestamp = getTime(orig.getCreatedAt());
    is_retweet = orig.isRetweet();
    final Status retweeted = orig.getRetweetedStatus();
    final User retweet_user = retweeted != null ? orig.getUser() : null;
    retweet_id = retweeted != null ? retweeted.getId() : -1;
    //NOTE getTime(orig.getCreatedAt())
    retweet_timestamp = retweeted != null ? getTime(retweeted.getCreatedAt()) : -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;
    retweeted_by_profile_image = retweet_user != null
            ? ParseUtils.parseString(retweet_user.getProfileImageUrlHttps())
            : null;
    final Status status = retweeted != null ? retweeted : orig;
    final User user = status.getUser();
    user_id = user.getId();
    user_name = user.getName();
    user_screen_name = user.getScreenName();
    user_profile_image_url = ParseUtils.parseString(user.getProfileImageUrlHttps());
    user_is_protected = user.isProtected();
    user_is_verified = user.isVerified();
    user_is_following = user.isFollowing();
    text_html = formatStatusText(status);
    media = ParcelableMedia.fromEntities(status);
    text_plain = status.getText();
    retweet_count = status.getRetweetCount();
    favorite_count = status.getFavoriteCount();
    reply_count = status.getReplyCount();
    descendent_reply_count = status.getDescendentReplyCount();
    in_reply_to_name = getInReplyToName(status);
    in_reply_to_screen_name = status.getInReplyToScreenName();
    in_reply_to_status_id = status.getInReplyToStatusId();
    in_reply_to_user_id = status.getInReplyToUserId();
    source = status.getSource();
    location = new ParcelableLocation(status.getGeoLocation());
    is_favorite = status.isFavorited();
    text_unescaped = toPlainText(text_html);
    my_retweet_id = retweeted_by_id == account_id ? id : -1;
    is_possibly_sensitive = status.isPossiblySensitive();
    mentions = ParcelableUserMention.fromUserMentionEntities(status.getUserMentionEntities());
    first_media = media != null && media.length > 0 ? media[0].url : null;
}