The with() function

This calls a given function or block of functions on that object and returns the result. For example, while working with RecyclerView we always bind our views using ViewHolder. The ViewHolder always sets the value for its child views.

With the help of POJO, we retrieve value out of POJO and set them on view. For the TweetAdapter class the showData function can look like the following if the programming language is Java:

    public void showData(Tweet tweet) {      imgProfilePic.setRoundedImageOption       (tweet.user.getProfileImageUrlHttps());       txtName.setText(tweet.getUser().getName());       txtHandler.setText(tweet.getUser().getScreenName());       txtTweet.setText(tweet.getText());    }

Did you notice everywhere we have to use a tweet object to ...

Get Kotlin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.