‫Welcome back.
‫In this video, we'll learn how to add the retrofit library to our applications and learn how to create
‫the data classes for it.
‫Let's go to square dot Github.io Slash retrofit Select Download.
‫Copy this gradle implementation and let's go to the GitHub to get the latest version.
‫Click on it and you can see the latest version is 2.9.0.
‫Let's create a new project in Android studio, select Empty Views Activity and I'll name it as the movie
‫app.
‫Click Finish, go to Gradle Scripts Build.gradle acts at the level of app and paste the dependency here
‫and the change the latest version to 2.9.0 and of course change it to this because I'm using Android
‫in the latest versions of Android studio.
‫So you need to add this double quotes and this parenthesis sync now and congratulations retrofit has
‫been added to your project.
‫I want from you to focus with me.
‫Let's review what we're going to fetch.
‫We're going to fetch an object called results.
‫The key is result and the value is an object containing four elements, four key values.
‫The first one is page and its value is one.
‫The second element is the results, which is an array containing 20 objects.
‫The third element is total pages, and the fourth element is total results.
‫We have three integer variables or values, the page, total pages and total results.
‫The values of these keys are integers and the results, which is the key.
‫An array containing 20 objects.
‫Please, guys, focus with me because we're going to learn how to fetch the data from Json format into
‫objects in Java or Kotlin.
‫After that, we need to fetch these 20 objects that are with different values.
‫So each item contains 14 key value pairs.
‫We're going to fetch these key value pairs step by step.
‫Let's go and implement this in Android studio.
‫I'll create a new package and I'll name it as model.
‫Inside this model, I'll create the model classes.
‫So at first I'll create a class called Result that fetches the whole result, the three integers and
‫one array.
‫I'll teach you at first how to get and understand the pojo classes by understanding the Json format.
‫And then in the next step we're going to implement a new method by using an online tool.
‫Here we have three three variables of type integers and one of type array.
‫So for that I'll create private integer.
‫The first variable is page.
‫So I'll create page.
‫The second variable is of type integer.
‫It's called total pages.
‫Pages.
‫The third one is integer.
‫Total results.
‫And the fourth element here is the results, which is an array of objects.
‫So for that I'll create a private list of movie object, which is a data class that we're going to create
‫in the next steps, and I'll name it as results equal to null.
‫And you can see the response is named as results.
‫Its key and its value is 2020 objects.
‫Now let's create this movie class.
‫And I'll use an online tool to create this pojo class.
‫Let's return to here the results.
‫Alt+ Enter to import the list.
‫Then I'll create the getters and setters for all of these variables and I'll create an empty constructor
‫here.
‫To prevent any possible null pointer exceptions.