‫After we have successfully added the dependencies of the libraries that we are going to use inside the
‫Paging App Project, we are going to make like a plan.
‫What we are going to do inside the code so that paging app will be created according to MVP M and the
‫Paging Library Retrofit and dagger health standards.
‫So this is the MVP AMP architecture.
‫And of course, when talking about retrofit, we are going to fetch the data from the API, which is
‫web service or online database.
‫So the remote data source would be as in retrofit.
‫I will segment this diagram into three parts.
‫As we have learned before, we have the view.
‫We have the view model and the model.
‫So the activity our our app will contain only one activity which is the main which displayed that movies
‫in recycler view and the view model, which is containing the view model and the live data and the model
‫which compromised the repository that a remote data source retrofit and the web service, we are going
‫to use the dagger hilt and we are going to introduce that paging library, which is the main goal of
‫this project.
‫So let's go to Android Studio.
‫Let's start creating the packages here and make everything clear.
‫So the packages, the first batch would be the model.
‫And inside the model, I will create two classes, the movie and the movie press.
‫So this is the movie.
‫And let me revise something very important about the movie TV.
‫After you sign up.
‫On that.
‫The movie DB dot org website.
‫You click on more API and get this page and we click on the developers, the movie DP documentation.
‫So this will loads that documentation.
‫And that from the previous exercises and previous app that we have seen that the API, the movie DB
‫arc, this is that constant link.
‫And this is that the end point link.
‫So this is the link that we are going to fetch and that we are going to edit according to our demands.
‫So.
‫So all the responses would be like this.
‫So I would copy this out of the details copy.
‫And I would go Jason for Defi online.
‫This is Jason for that org.
‫This is a good website for defining the JSON response and we paste our response.
‫So here we are.
‫We go.
‫We have that pretty fine once.
‫By the way, in this app, we are not going to fetch and get all the data that this JSON response will
‫be displaying for us.
‫So we are going to only fetch that name, the ID and the poster path, which is the image and the vote
‫average.
‫Okay.
‫So.
‫Another important thing that I should mention for you if we go to developers dot they're movie DB dot
‫org slash three strata slash getting started and introduction which is that API for the documentation
‫for the developers to scroll down to the movies.
‫And we are going to get that popular.
‫Okay.
‫This is the ad that get request that we are going to work with and this is the page which is an integer
‫that we are going to use the page or at the view at the paging library with it.
‫Okay.
‫So if we go to here and specify the API key, let me and this is my API key.
‫I really copied and pasted here and send request.
‫It will give us this.
‫Okay.
‫There is an error.
‫Check developer tools.
‫There is.
‫We will get here.
‫This page equal to one.
‫So if we specify page 4 to 5, that page equal to five has been added.
‫So if we remove the page, the request here will be will be removing the page, which is the default
‫one page equal to one.
‫So guys, I want from you to understand why we are going to use that page and for this send request,
‫this request.
‫And when specifying the API key in the previous exercises and previous API calls like the movie DB and
‫the pro movie app that we have, build it before.
‫We didn't specify the number of the page, but now we are going to fetch that data according to the
‫pages.
‫So if the user scroll light down for five pages and need to display the first 50 movies, we are not
‫going to display that 1 million and all the movies on site inside that movie DB database, we are going
‫to fetch only the first 50 and this is why we are going to use that page library and paging library.
‫Okay, so here we are going to fetch that data according to the pages.
‫Okay.
‫No, this is the JSON response that we are going to get.
‫As I mentioned, we need the I.D. we need that poster path and we need the vote.
‫Vote count or vote average.
‫Okay.
‫So these are the three things that we are going to get from the movie DP The Talk.
‫But there is one other thing that I should remember when fetching data from the movie D.B. That response
‫would be not not in form of like a planned Jason inside and all inside one array.
‫They are included in nested things like the page results, total pages and total results, for example.
‫So if we go to the definition here and scroll down, the response here will get inform of this.
‫It is an object and having that page as integer.
‫The result, which is the array of movies which is a movie list, result, object, total results and
‫the total pages.
‫So the response of Jason or the movies list is not in form of a simple object.
‫It is inside a big object, and inside this object containing four things for attributes the page results,
‫total results and total pages.
‫And inside the result there are that date of the movie that we are going to get, which is the poster
‫path, the idea and the vote average.
‫So I want from you to understand this and this hierarchy.
‫We are going to create two classes of Modal in in order to get and fetch the data of Jason correctly.
‫So the first one is the movie and the second one is the movie response.
‫The movie response here.
‫As I told you, this is the big response.
‫This is the whole response fetching also the results.
‫Okay.
‫So here we start by creating that serialized annotation, that apt serialized name, which is the page
‫here.
‫So we are getting that object in JSON and expose annotation and we start by creating their private integer
‫integer page.
‫Okay.
‫Now we create a serialized name which is results in the same name as here results.
‫It's case sensitive.
‫So we are telling that I am putting all the pages here, all data of this, which is an integer.
‫I can make it as and inside this page number and also here expose.
‫I'm putting all the results inside our list because it results here.
‫It returns a list of movies.
‫Okay.
‫And array of objects.
‫Array of type object.
‫What is this object is of type movie.
‫So, guys, please concentrate with me.
‫Array of object.
‫What is the type of object?
‫It's a movie.
‫So I will create a class and model class for the movie object.
‫Okay.
‫So private list.
‫List of movie
‫and called movies equal to no.
‫Okay.
‫Oh.
‫Plus, enter to import the collection phrase list.
‫And now I will create serialized.
‫Serialized name.
‫It's named as.
‫Here the total results, its case sensitive.
‫Total
‫results.
‫And expose.
‫Drive it and total results.
‫And in the same way I watch copy and paste here.
‫The.
‫Total pages total.
‫Pages.
‫Although this is very important.
‫Okay.
‫Now, let's get and set the methods for these variables here.
‫And the third getter and setter.
‫And here we go.
‫These are the getters and setters methods.
‫Now let's go to that movie.
‫And as I told you, the movie is an object.
‫And the result is an array of of these objects.
‫So what we are going to get from this object, I need the idea that poster path and the vote average.
‫So I would go to here.
‫And in the same way I would make since we are working with Jason serialized name.
‫What is this name?
‫It's called ID.
‫So this is that ID?
‫It's case sensitive.
‫Also expose.
‫And we are going to gapped and create private and I.D. now.
‫Second one, serialized name poster path which is here is string, bolster, underscore, path
‫and expose.
‫And the private string poster path.
‫Ex serialize name vote underscore average
‫expose.
‫And private double vote average.
‫Okay.
‫So this is the vote average.
‫Okay.
‫In the same way getters and setters for all.
‫So these are their getters and their centers for that.
‫For now, we have we have checked them.
‫Model model classes and we have created and now let's override one less thing which is the Boolean equal.
‫APT override.
‫Equals.
‫And I need to.
‫Members.
‫Teen angst.
‫Angst equal to and hashCode.
‫I don't need to hashCode.
‫I need to get my own.
‫If oh equal equals to null, then return false.
‫And if all equal equals to this, then return to do I return false.
‫Okay.
‫This checking for the equal.
‫And this way we have finished.