Example usage for twitter4j User getName

List of usage examples for twitter4j User getName

Introduction

In this page you can find the example usage for twitter4j User getName.

Prototype

String getName();

Source Link

Document

Returns the name of the user

Usage

From source file:com.twitstreet.db.data.Stock.java

License:Open Source License

public Stock(twitter4j.User twUser) {
    this.setId(twUser.getId());
    this.setLongName(twUser.getName());
    this.setName(twUser.getScreenName());
    this.setTotal(twUser.getFollowersCount());
    this.setPictureUrl(twUser.getProfileImageURL().toExternalForm());
    this.setSold(0.0D);
    this.setVerified(twUser.isVerified());
    this.setLanguage(twUser.getLang());
    this.setCreatedAt(twUser.getCreatedAt());
    this.setLocation(twUser.getLocation());
    this.setDescription(twUser.getDescription());
}

From source file:com.twitt4droid.data.dao.impl.sqlite.UserSQLiteDAO.java

License:Apache License

/** {@inheritDoc} */
@Override//  w w  w.  j  a v  a  2 s .c om
public void save(User user) {
    getSQLiteTemplate().execute(getSqlString(R.string.twitt4droid_insert_user_sql),
            new String[] { Objects.toString(user.getId()), user.getName(), user.getScreenName(),
                    user.getProfileImageURL(), user.getProfileBannerURL(), user.getURL(), user.getDescription(),
                    user.getLocation() });
}

From source file:com.twitt4droid.fragment.UserTimelineFragment.java

License:Apache License

/**
 * Sets up the user GUI./*from  w  w  w.  jav a2  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 v a 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//ww w.j  a v a  2 s.  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;
    }//w w w  .  j  av a  2 s .  c om

    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:com.zisal.twit.crawl.core.Example.java

public static void main(String[] args) {
    Twitter twitter = new TwitterFactory().getInstance();
    twitter.setOAuthConsumer(ApplicationConstant.TwitterKey.CUSTOMER_KEY,
            ApplicationConstant.TwitterKey.CUSTOMER_SECRET);
    twitter.setOAuthAccessToken(//w  ww  . j  a  va 2s.  c  o  m
            new AccessToken(ApplicationConstant.TwitterKey.TOKEN, ApplicationConstant.TwitterKey.TOKEN_SECRET));
    /*try{
    ResponseList<Status> responseList = twitter.getUserTimeline(new Paging(1, 5));
    for(Status s: responseList){
        System.out.println("Response List ".concat(s.getText()));
    }
    }catch(Exception e){
    e.printStackTrace();
    }
            
    long cursor = -1;
    IDs ids = null;
    System.out.println("Listing followers's ids.");
    do {
    try {
        ids = twitter.getFollowersIDs(ApplicationConstant.Twitter.SCREEN_NAME, cursor);
        for (long id : ids.getIDs()) {
            System.out.println(id);
            User user = twitter.showUser(id);
            System.out.println(user.getName());
        }
    } catch (TwitterException e) {
        e.printStackTrace();
    }
    } while ((cursor = ids != null ? ids.getNextCursor() : 0) != 0);*/

    long cursor = -1;
    PagableResponseList<User> pagableFollowings = null;
    List<User> listFriends = new ArrayList<>();
    do {
        try {
            pagableFollowings = twitter.getFriendsList(18211861, cursor);
            for (User user : pagableFollowings) {
                listFriends.add(user);
                logger.info(ApplicationConstant.LogTag.ZUNA_INFO, "friend #1st level " + user.getName());
                /*PagableResponseList<User> _2ndLevelPageableFollowings = twitter.getFriendsList(user.getId(), cursor);
                for(User _2ndLevelFriend : _2ndLevelPageableFollowings){
                logger.info(ApplicationConstant.LogTag.ZUNA_INFO, "added friend #2nd level "+ _2ndLevelFriend.getName());
                listFriends.add(_2ndLevelFriend);
                }*/
            }
        } catch (TwitterException e) {
            e.printStackTrace();
        }

    } while ((cursor = pagableFollowings.getNextCursor()) != 0);

    logger.info(ApplicationConstant.LogTag.ZUNA_INFO, "friend total : " + listFriends.size());
    for (User user : listFriends) {
        logger.info(ApplicationConstant.LogTag.ZUNA_INFO, "friend : " + user.getName());
    }

    /*
            cursor = -1;
            PagableResponseList<User> pagableFollowers = null;
            List<User> listFollowers = new ArrayList<>();
            do {
    try {
        pagableFollowers = twitter.getFollowersList(twitter.getId(), cursor);
        for (User user : pagableFollowers) {
            listFollowers.add(user); // ArrayList<User>
            System.out.println(user.getName());
        }
    } catch (TwitterException e) {
        e.printStackTrace();
    }
            
            } while ((cursor = pagableFollowers.getNextCursor()) != 0);
    */

}

From source file:DataCollections.FriendsnFollowersCollection.java

public ArrayList<User_dbo> collectfriendsfollowersofuser(User_dbo cuserdbo) throws InterruptedException {
    long cursor = -1;
    PagableResponseList<User> list;
    User user;
    User_dbo userdbo;/*from  www .j a  v  a2s.c o m*/
    ArrayList<User_dbo> userdbolist = new ArrayList<>();
    boolean available = true;
    Logger.LogPrinter.printLog(
            "Retrieving friends of the user  " + cuserdbo.values[User_dbo.map.get("screename")].string);
    while (available) {

        try {
            list = ffresources.getFriendsList(cuserdbo.values[User_dbo.map.get("user_id")].lnumber, cursor);
            ListIterator li = list.listIterator();
            while (li.hasNext()) {
                user = (User) li.next();
                LogPrinter.printLog("" + user.getName());
                userdbo = userhelper.convertUserToUser_dbo(user);
                userdbolist.add(userdbo);
                //LogPrinter.printLog(" Friend retrieved"+userdbo.values[User_dbo.map.get("screename")].string);
            }
            if (list.hasNext()) {
                cursor = list.getNextCursor();
            } else {
                available = false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            Logger.LogPrinter.printLog(" Sleeping... rate limit exceeded will try after " + 900 * 1000);
            Thread.sleep(900 * 1000 + 500);

            LogPrinter.printLog(" Message " + e.getMessage());
        }
    }
    LogPrinter.printLog("No of friends retrieved: " + userdbolist.size());
    available = true;
    cursor = 0;
    Logger.LogPrinter.printLog(
            "Retrieving followers of the user  " + cuserdbo.values[User_dbo.map.get("screename")].string);
    while (available) {

        try {
            list = ffresources.getFollowersList(cuserdbo.values[User_dbo.map.get("user_id")].lnumber, cursor);
            ListIterator li = list.listIterator();
            while (li.hasNext()) {
                user = (User) li.next();
                userdbo = userhelper.convertUserToUser_dbo(user);
                userdbolist.add(userdbo);
            }
            if (list.hasNext()) {
                cursor = list.getNextCursor();
            } else {
                available = false;
            }
        } catch (Exception e) {
            Logger.LogPrinter.printLog(" Sleeping... rate limit exceeded will try after " + 900 * 1000);
            Thread.sleep(900 * 1000 + 500);

            LogPrinter.printLog(" Message " + e.getMessage());
        }
    }
    LogPrinter.printLog("No of friends/follwers retrieved: " + userdbolist.size());
    return userdbolist;
}

From source file:DataCollections.UserHelper.java

public User_dbo convertUserToUser_dbo(User user) {

    User_dbo u = new User_dbo();
    u.values[User_dbo.map.get("user_id")].setValue(String.valueOf(user.getId()));
    u.values[User_dbo.map.get("name")].setValue(removeEscapeCharacters(user.getName()));
    u.values[User_dbo.map.get("screename")].setValue(removeEscapeCharacters(user.getScreenName()));
    u.values[User_dbo.map.get("lang")].setValue(user.getLang());
    u.values[User_dbo.map.get("location")].setValue(removeEscapeCharacters(user.getLocation()));
    u.values[User_dbo.map.get("geoenabled")].setValue(String.valueOf(user.isGeoEnabled()));
    u.values[User_dbo.map.get("timezone")].setValue(user.getTimeZone());
    u.values[User_dbo.map.get("profileurl")].setValue(user.getURL());
    u.values[User_dbo.map.get("protected")].setValue(String.valueOf(user.isProtected()));
    u.values[User_dbo.map.get("verified")].setValue(String.valueOf(user.isVerified()));

    u.values[User_dbo.map.get("description")].setValue(removeEscapeCharacters(user.getDescription()));

    if (geoinfoavailable) {
        double[] geocoor = geohelper.searchGeoLocCoor(user.getLocation());
        u.values[User_dbo.map.get("probased_geoinfo")].setValue(String.valueOf("true"));
        //u.values[User_dbo.map.get("descbased_geoinfo")].setValue(String.valueOf("false"));
        u.values[User_dbo.map.get("probased_lat")].setValue(String.valueOf(geocoor[0]));
        u.values[User_dbo.map.get("probased_lon")].setValue(String.valueOf(geocoor[1]));
    }//  www .j a v a  2 s  .com
    u.values[User_dbo.map.get("udetails_processed")].setValue(String.valueOf(true));
    u.values[User_dbo.map.get("totaltweets")].setValue(String.valueOf(user.getStatusesCount()));
    return u;
}

From source file:de.binfalse.jatter.processors.JabberMessageProcessor.java

License:Open Source License

/**
 * Translate user./*w w w  . j  av  a2s .  c o m*/
 *
 * @param user the user
 * @param profile the profile
 * @return the string
 */
public static String translateUser(User user, String profile) {
    String ret = "profile of *" + profile + "*\n" + "name: " + user.getName() + "\n" + "screen name: "
            + user.getScreenName() + "\n" + "id: " + user.getId() + "\n";

    if (user.getDescription() != null)
        ret += "description: " + user.getDescription() + "\n";
    if (user.getURL() != null)
        ret += "url: " + JatterTools.expandUrl(user.getURL()) + "\n";
    if (user.getLang() != null)
        ret += "language: " + user.getLang() + "\n";
    if (user.getLocation() != null)
        ret += "location: " + user.getLocation() + "\n";
    if (user.getTimeZone() != null)
        ret += "time zone: " + user.getTimeZone() + "\n";

    ret += "tweets: " + user.getStatusesCount() + "\n";
    ret += "favourites: " + user.getFavouritesCount() + "\n";
    ret += "followers: " + user.getFollowersCount() + "\n";
    ret += "friends: " + user.getFriendsCount() + "\n";

    if (user.getStatus() != null)
        ret += "last status: " + TwitterStatusProcessor.translateTwitterStatus(user.getStatus());
    return ret;
}