Displaying Data From Code
In this lesson, we will implement the recycler view adapter to render a list of blog articles.
We'll cover the following...
We'll cover the following...
Loading data from the Internet #
During the previous lessons, we created a BlogHttpClient which loads a list of blog articles. Let’s modify our code to support the new JSON format.
Old JSON format:
The main changes in the new JSON format are:
- we have
idattribute - the
imageandavatarnow contain a relative path
In the BlogHttpClient, we need to change the URL to the following:
This gives us the ability to concatenate BASE_URL with the relative path of blog image or author avatar. Let’s add additional get methods to Author class and Blog class which are going to return full image URLs.
Now, we can modify MainActivity code and add a blog loading code similar to what we have in BlogDetailsActivity.