Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
We’ve set up our app project and now we’re ready to display a list of items from Etsy. To help us interact with the Etsy API we’re going to use two helpful open source libraries, Picasso and Retrofit.
Be sure to check for the latest versions of these libraries available at the sites below:
-
Picasso: lets us load images from the internet without worrying about advanced topics like caching, multi-threading, or memory constraints.
-
Retrofit: enables us to create readable Java interfaces and classes that match the API we are accessing, as well as allowing us to interact with simple Java objects instead of having to parse network responses manually
Bring in Picasso and Retrofit to your API
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
Learn about Parcelable with Android Tools
[MUSIC]
0:00
Welcome back.
0:04
We've set up our app project and
0:05
now we're ready to display
a list of items from Etsy.
0:07
To help us interact with the Etsy API,
0:11
we're gonna be using two
helpful open-source libraries.
0:13
The first is called Picasso.
0:17
It allows us to load images from the
internet without worrying about advanced
0:19
topics like caching, multi-threading,
or memory constraints.
0:23
The second is called Retrofit.
0:28
Retrofit enables us to create
readable Java interfaces and
0:30
classes that match
the API we're accessing.
0:34
It also allows us to interact with
simple Java objects instead of having to
0:37
parse network responses manually.
0:42
Both Picasso and Retrofit are provided
by the same company, Square,
0:44
which provides other libraries used at
TreeHouse, like OkHttp and Butterknife.
0:49
To add these to our project,
we need just two lines of code.
0:55
Let's jump in and get started.
0:59
Code libraries can be added just like
we did for Google Play Services.
1:02
We open our build.gradle file.
1:07
Here in the aptly named
dependencies section,
1:08
we can add two lines to bring in
Picasso and Retrofit to our project.
1:11
Compile statements start with the word
compile, then contain a string,
1:16
and it has three parts.
1:19
The first part is the project name.
1:21
The second part is
the specific library we want.
1:23
This is sometimes referred
to as the artifact.
1:25
The final part is the version
of the artifact that we want.
1:28
The latest version can be found by
checking the place where the code is
1:31
posted online.
1:34
I've provided links to these
two projects in the teacher's
1:35
notes to make sure you
grab the latest version.
1:38
Let's go ahead and
add in new dependencies for Picasso.
1:41
[SOUND] We're gonna use
com.squareup.picasso,
1:44
and the artifact is Picasso, and
1:50
the version right now is 2.5.0.
1:54
And for Retrofit, also from Square,
1:59
[SOUND] version is 1.9.0.
2:05
And again, every time that we
change our build.gradle file,
2:10
we're going to have to go ahead and
sync again.
2:13
So let's click Sync Now.
2:15
Now that our sync is done,
2:17
we can use the code in these
libraries that we've just added.
2:20
We'll get to that in a bit, but
let's take a short break and
2:22
then we'll add a few more classes to
our project to help us model our data.
2:25
You need to sign up for Treehouse in order to download course files.
Sign up