‫Hello my friends.
‫In this video I will create the adapter for this card view to be displayed inside the recycler view.
‫I've added the layout tag here in this layout in order to use the data binding with the journal row
‫inside the adapters.
‫So I will create.
‫New Kotlin class.
‫I will name it as journal.
‫Recycler.
‫Adapter.
‫And this class will be as a data or sorry, a recycler adapter.
‫Class.
‫So it took into the parameter it a variable of type context.
‫So val context type context and a var of type list.
‫List of journal.
‫Type journal or list of type drawn.
‫Okay.
‫Now this class, I will tell Android studio that it will act as a recycler view adapter.
‫So I will extend from recycler view dot adapter and I will pass here my view holder.
‫So you can see I need to pass an object of recycler view or data type of recycler view holder.
‫I will create my view holder class here.
‫I will create my inner class, public class, my view holder.
‫It extends from recycler view dot view holder and I will add here Alt+ enter to change to constructor
‫invocation.
‫And this is an inner class acting as if you hold.
‫Alt+ Enter to change constructor invocation and Alt+ enter to make it as journal Recyclerview and direct
‫it to this.
‫So I am indicating that this type of view holders are as an inner class declared here.
‫Okay.
‫Now.
‫Let me continue with this journal recycler adapter and I will create an initiate and initialize this
‫context or the context.
‫I will create here.
‫Or I don't need it.
‫I need to implement the method.
‫So I will create.
‫The three methods implement them.
‫The Oncreate view holder unbind view holder and get item count.
‫Select them all.
‫Click.
‫Okay.
‫And here we go.
‫We need to set this view Holder.
‫Oncreate.
‫Viewholder.
‫Unbind Viewholder and get item count methods.
‫Let's start with the Oncreate view holder.
‫I will create val view.
‫It's of type view equal to layout inflator dot from and I will pass the context here.
‫Then I need to use inflate and I need to pass the layout that I need to inflate.
‫R dot layout dot journal row.
‫The second parameter is the view row or the view type here.
‫The parent.
‫View group and the view type.
‫I don't need to use it.
‫I will use false as attach to route.
‫Return new.
‫I remove this new view?
‫My view holder.
‫My view Holder and I will pass the two parameters here.
‫I have created the stack at this class without using the constructor.
‫The correct constructor.
‫I need to pass two things the view that I have created here and the context.
‫Okay.
‫Now, I need to change the constructor here.
‫So I need to add constructor parameter item view.
‫Like this.
‫And this context add parameter to the context refactor.
‫And here we go.
‫My viewholder took two parameters the view item, view and the context.
‫Now let's move to the unbind Viewholder.
‫Method.
‫This method will allow us to set the correct things, the correct data to the correct widgets.
‫I will create a journal, Val.
‫A journal?
‫It's of type journal.
‫Journal and its equal to journal lists.
‫Journal list dot get and here I need to pass the position variable from here.
‫So it's a parameter passed here as also as a parameter in the get method.
‫Now.
‫I will create Val or var string image url.
‫It's of type string and I will initialize it as.
‫Empty string.
‫Now I will use the data binding here.
‫So the data binding data binding.
‫Binding, Val.
‫Binding equal to.
‫Date.
‫Uh, the data binding util dot.
‫Get.
‫Or I will not use the set content view.
‫I will use directly the data binding so it's of type binding object equal to.
‫And I need to set here the correct layout for it, so I'll use journal row binding.
‫Okay.
‫And this is actually the old way how we we use the unbind viewholder and the adapter class without using
‫the data binding init.
‫So I will move this data binding to here and in the next video I will show you how to add.
‫Late in shade.
‫How to add this data binding library to the recycler views and the recycler.