‫Hello, my friends.
‫In the previous video, we have created a new package called Adapter and we have created the movies
‫and and now in this video, we are going to create a new Java class called Movies Load State and at
‫movies load state at that.
‫And this wall extends extends from load stayed that this is the load state adapter which is included
‫into paging library and this what we have talked about in the previous video.
‫So it's part of the paging library that will allow the users that the users to display the movies into.
‫So if we go to the documentation, that load state adapter is an adapter for displaying a recycler view
‫item based on load state such as loading spinner or retry error.
‫But by default, we'll use one shared view type for all items and by default both load state of clothing
‫and load state error are presented as adapter items.
‫Other states are not.
‫Okay.
‫So.
‫A movie's load stayed at after the load.
‫They view what I would create now that this class.
‫And then this is this is the internal class.
‫And then we are going to create to continue creating this class so public that take the class load state
‫you all learn.
‫This is the view holder of extends from recycler view the to view home so it acts as if you hold the
‫inside sectors.
‫Define the progress for private progress bar.
‫For Progress Bar.
‫Define an error.
‫Text view.
‫Private text.
‫Private text view.
‫Error message.
‫Oh.
‫Plus entering for text to view class and private bottom.
‫M retry hopeless entertaining path but now load state the view of alter.
‫This is the constructor.
‫Constructor.
‫I will make it to the parent and the clerk.
‫So I will select none.
‫It will to the view group of you grew.
‫I would name it as parent and plus entity and part of the package and none.
‫None.
‫None, none.
‫Viewed on click and listener that I read today called back I would make them like this and here super
‫lay out insulator because we have extends from recycler view to the view hauler and so we need to edit
‫this from that context per in the get context and we inflate this to inflate what we are going to inflate
‫are totally out or load load help us entity import are.
‫Load.
‫State item.
‫This is the layout that we have created before.
‫And here the attached truth as false.
‫Okay.
‫No load.
‫State item.
‫Item binding.
‫This the binding binding have created loading state.
‫Loading or load state item by combined item view.
‫What is the item view here and the item view that we have created before?
‫And AMP progress or equal to binding the progress bar and or equal binding.
‫This is the binding library that we have worked where error message and m retry equal binding that retry
‫bottom.
‫I'm retry not set on clicklist and our retry call back.
‫Okay.
‫No, we will create a new method called bind.
‫Public.
‫Bind.
‫Public.
‫Void.
‫Bind.
‫We passed the load state.
‫Which is for the Beijing Library and called the low state of placentas to be part of the package.
‫So if load the state.
‫Instance, off load state the error.
‫Then what to do?
‫You get that error by creating the load state that we have talked about.
‫It got error load state error equal.
‫We make the casting for it.
‫Load the state not error load state.
‫Set the text of the error message error to accept to load state error to get error, not get a localized
‫message.
‫Set the visibility of the widgets based on the load state.
‫So I'm progress bar the set visibility to load state if there's an instance of load the state the loading.
‫So we are going to make it visible loading.
‫If it is like this is an instance of.
‫Let me make this loading.
‫Is it equal to view the earth visible then?
‫If it is load as instance of load state loading, then make it as visible.
‫Otherwise make it that view that gone.
‫So remove it if it is not an instance.
‫If Load State is not an instance of loading state.
‫Okay.
‫So we have checking the load state.
‫If it is loading, then make it as visible.
‫Otherwise make it gone.
‫If it is loading so display their progress but it is not loading if it has have finished loading or
‫it is not loading due to any error of of the network or connection or API or coding, then make it is
‫gone.
‫Okay.
‫No, I will copy the same face to it three times because the first one is the progress bar to the second
‫one is m retry.
‫So if m retry set visibility load.
‫The state is an instance of load the state error, then make it make it visible.
‫Otherwise make it gone.
‫So if the loading state that this passed to the bind, it is a an instance of loading make the progress
‫bar visible.
‫If it is an instance of error, make the emirate try a visible.
‫Otherwise, if m ordered the load state.
‫If it is a load state that error, then make also the AM error message visible
‫error message.
‫That said visibility load state instance of load the state that error.
‫Okay, so view equal visibility.
‫Otherwise it will be gone.
‫Till now we have created this method.
‫We passed the load state and this check if the load state is an error.
‫So if it is an error, we will set that text to get error that gets equalized at message.
‫So otherwise if it is loading, then it will display the progress bar.
‫If it is not loading, it is an error.
‫It will display error, retry.
‫It will make the retry, which is a retry button and it will display an error message with which is
‫an error message, which is a text to view.
‫Okay, so error message, text view retry will become which is a button.
‫This two will be displayed within when there is an error in displaying the load state.
‫And if it is in loading load state, it will display the progress bar.
‫This is the aim of using such a method.
‫Okay.
‫Now let's go up and start creating and continue creating with movies, load state and app so it will
‫define the retry callbacks.
‫Private View.
‫Dot on click listener.
‫Retry Callback.
‫And I will create public movies
‫notes state adapter for you the town clerk lesson or retry call back.
‫Brit, try this the emir try called back equal or try?
‫Call back.
‫And.
‫Since we are using a load state adapter which defines and which extends the recycler view holder, we
‫need to implement the two methods that we have already seen in the previous video, which is the Anchorage
‫View Holder and combined view holder.
‫So if I click out plus enter, implement the methods and I will implement it here on point of view holder,
‫the holder and the load state.
‫So Holder load state of view holder and bind load state.
‫This is.
‫The bind of you.
‫Holder called bind method to bind visibility of the view.
‫So we are going to call this method called bind now that on create a view or holder on create view holder
‫take the parent here.
‫I prefer to name it as parent and the load state it will return you load the state view holder parent.
‫I'm retry call back.
‫So this is the.
‫Class, the load state adapter, which extends from Load State adapter.
‫And this is very important for the paging and it's part of the Paging Library.
‫So congratulations we have done in creating that adapter.