‫Hello, my friends.
‫In the previous videos, we have learned about the structure of the Paging Library.
‫So we have talked about it contains three structures, the paged list adapter, the paged list and the
‫data source we have configured till now the data source in this video, we are going to create the page,
‫the list adapter and by the for remembering view that this is the structure for the paging to.
‫But since we have used the paging to paging three and we have updated the paging three library, so
‫the page list adapter will becomes Beijing data adapt.
‫So in this video we are going to create a class that is responsible for paging data adapter creation
‫and extending.
‫So let's begin and let's migrate from paging to to paging three in in mind because we are not going
‫to implement painting do we are going to implement directly paging three.
‫I will create here in you package called adapter and inside this and after I will create a new Java
‫class called movies and Adapter and this class will acts as a paging data adapter, so extends Beijing
‫data adapter
‫and it took into that type parameters, the movie, the movies adapter, the movie view, all the pieces,
‫the class that we are going to create.
‫Now, I will implement this import this class.
‫And I will create this letter.
‫Or let me create that before making anything in order to make sure every and every implemented and overriding
‫method will be implemented directly so.
‫Public class movie view called.
‫Extends.
‫Recycler view the view of.
‫What this will make of plus enter to create the matching constructor.
‫Okay.
‫I will remove it because I need to add one another single movie item.
‫This is the class for defining the movie item layout view binding.
‫So I'm using now that model and the data binding.
‫If you are a single movie item biting.
‫So you see, guys, this is a single movie, right?
‫In order to use their view that you're binding.
‫Please go back to the previous courses in order to learn more about view binding.
‫But in in a fast recap for this library, in order to use a single movie item, we put the name of the
‫layout in this way in the camel case movie item, and we add the word binding to it in order to use
‫this library.
‫So I would name it as movie item binding, and here I am, plus enter.
‫I will not create it till now because I need to implement its dependency.
‫Okay.
‫Now.
‫Import the class for paging data adapter.
‫It's good public movie view of older you older and here.
‫None.
‫Single movie item.
‫Binding it into the parameter like this.
‫Like.
‫Okay.
‫Super movie light and binding the cat the Lord
‫and initiate the binding this movie the binding equal to movie bind.
‫Okay, now let me add the view model and data binding sorry, the view binding dependency.
‫So if we go to developers the Android dot com slash topic slash library slash view binding, we can
‫see that the view binding here that allows you more easily to write code that interacts with the views
‫and wants the views that by view binding is enabled in the model that generates a binding class for
‫each example late out file percent in that model and that what we have done so in order to add this
‫we go to that.
‫This is the groove in this for Scotland, so we will copy it.
‫And we go to the build that Granville.
‫More to.
‫And the Android section.
‫This is the Android section and we see that there is a build features, compile options, build types,
‫default config.
‫I prefer putting it here.
‫So if we click on sync now, it will sync at.
‫And you see guys if we click on health plus enter it imported the class which is.
‫Which is here from their data binding.
‫Okay.
‫So this is stuff you.
‫Move if you hold.
‫Now, let's go up back to the movie and actor.
‫And inside this I will define a loading if you type.
‫So public static final int loading item equal to zero.
‫And I will define in movie view type, public static final and more v underscore I am equal to one.
‫No request manager.
‫Okay.
‫Like, I remember it as kind.
‫No.
‫Alt plus enter to create the constructor and I will add the data.
‫Paging data adapter.
‫This is and request manager.
‫So click.
‫Okay.
‫Click.
‫Okay.
‫The default.
‫You see it if you steal item called back.
‫This is the default deal.
‫We have lectured in previous videos about the movie and we have added it into the secular view.
‫None.
‫I will remove that coal routine, dispatch her and I will keep the request.
‫Manager declined.
‫So this will act as super this coal back and this glide equal to black.
‫Okay.
‫No.
‫There are two methods that we have.
‫We have learned about them in all the cycler view adapters that we have created.
‫So a plus enter to implement the methods all create view holder and on bind of you all.
‫So these are the two methods on create view holder and on bind view.
‫Hold that.
‫The first one in uncreative you hold her I will return move if you hold her return movie you hold her
‫And what are the parameters?
‫Single single movie item binding to inflate this is the further out what we are going to inflate we
‫are going to use to lay out inflate her though from.
‫From parent or cat context.
‫Verdant and false.
‫Attached to it.
‫Okay.
‫This is for.
‫That inflation and we have messed here.
‫Then you.
‫Okay.
‫This is for the on create fuels.
‫Let's move to the bind of you holder method.
‫We have the holder and we have the position.
‫So get the current move to create movie instance.
‫Current movie people get item.
‫Composition.
‫Now check for novel if current movie does not equal to now.
‫Then what we would do?
‫Line thought no.
‫What is that?
‫And that constant.
‫Or your URL that's used for the images.
‫Let's go back to the API says the movie DB dot org.
‫We click on API, we append nestling.
‫And we scroll down to the images here.
‫Images, and we see that.
‫All the images that for example four with equal 500 we they start with that constant you are l and this
‫is the name of the image.
‫So if we take an example of a movie that is passed from the API.
‫We see that there is a poster path or a local path here, logo path, logo pass.
‫And if we get the poster path here, we see that that is a.
‫Name of the image, the extension jpt jpg but there is no link.
‫So if we put this copy or go.
‫Go to this copy and paste it here.
‫We don't get anything.
‫Get a google search.
‫So we need a constant u r l in order to display this image and the constant u r as I told you that this
‫image, the TMD, be that or slash the slash slash the width that you need.
‫And I will copy this paste here that this is that constant path and this is the name of the image with
‫extension.
‫If we click on Enter and we get the image of the movie.
‫So this is the way that we need to fetch the data.
‫So I would copy the constant u r l I would go back to here.
‫I will load this.
‫Plus I will put the current movie dot get poster path.
‫We are getting the variable u r and.
‫Okay.
‫Dot into all the dot movie item binding dot image view movie.
‫Set the rating of movie called or dot movie item binding text if you buy rating set text to string the
‫value of current movie the get the vote average and we display it as this okay, this is how we get
‫that vote average.
‫So I want from you to understand there is a constant you are out that we are going to fetch all of us.
‫This is a constant part.
‫This is string and this is a variable Y according to the current movie.
‫It will display that get poster path and put this.
‫Like, for example, this link and this name of the image.
‫Alongside with this, in order to display the correct image.
‫One last method I need to make and overwrite is get the view type.
‫I override it?
‫Public
‫health.
‫Enter.
‫Override.
‫Get them out of you.
‫And this is the method.
‫A return.
‫Position.
‫Equal.
‫Equal to that item of item count.
‫It is equal to more every item.
‫Then make the and put it as a clothing item equal to zero.
‫Okay.
‫If get item count equal, is it equal to them move item.
‫So the position, if it is equal to get item count, then make it as movie eight which is one.
‫Otherwise position equal to loading item, which is c.
‫Okay.
‫I will save it.
‫And till now we have created the movies and in the next video we are going to create another adapter
‫inside this package called Movies Load State.