package Ġcom . example . mov iet op . view . adapter Ċ Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . navigation . Navigation Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . example . mov iet op . databinding . Row Movie Binding Ċ import Ġcom . example . mov iet op . service . model . Favorite Model Ċ import Ġcom . example . mov iet op . service . model . Movie Model Ċ import Ġcom . example . mov iet op . view . All F avorites Fragment Directions Ċ import Ġcom . example . mov iet op . view . view holder . Favorite ViewHolder Ċ Ċ class ĠF avorite Adapter ( private Ġvar Ġmovies : ĠList < Favorite Model > ?, Ġval Ġclick Listener : Ġ( Favorite Model ) Ġ-> ĠUnit ): ĠRecyclerView . Adapter < Favorite ViewHolder >() Ġ{ ĊĊĠĠĠ Ġprivate Ġvar Ġm Favorite List : ĠList < Favorite Model > Ġ= Ġarray ListOf () ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠF avorite ViewHolder Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbinding Ġ= ĠRow Movie Binding . inflate ( LayoutInflater . from ( parent . context ), Ġparent , false ) ĊĠĠĠĠĠĠĠ Ġreturn ĠF avorite ViewHolder ( binding ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Bind ViewHolder ( holder : ĠF avorite ViewHolder , Ġposition : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġholder . bind ( mF avorite List [ position ], Ġclick Listener ) ĊĠĠĠĠĠĠĠ Ġholder . setImage ( mF avorite List [ position ]. poster ) ĊĠĠĠĠĠĠĠ Ġ/* holder . item View . setOnClickListener { ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmovie Id Ġ= Ġm Favorite List [ position ]. id ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġaction Ġ= ĠAll F avorites Fragment Directions . action All F avorites Fragment To Movie Fragment ( movie Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNavigation . find Nav Controller ( holder . item View ). navigate ( action ) ĊĠĠĠĠĠĠĠ Ġ}*/ ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠgetItem Count (): ĠInt Ġ{ ĊĠĠĠĠĠĠ Ġreturn Ġm Favorite List . count () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġupdate F avorites ( list : ĠList < Favorite Model > ){ ĊĠĠĠĠĠĠĠ Ġm Favorite List Ġ= Ġlist ĊĠĠĠĠĠĠĠ Ġnotify DataSet Changed () ĊĠĠĠ Ġ} Ċ Ċ }