package Ġcom . example . p mo lo i . cut crease Ċ Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget .* Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . example . p mo lo i . cut crease . model . Product Ċ import Ġcom . example . p mo lo i . cut crease . view model . Product ViewModel Ċ import Ġcom . squareup . pic asso . Pic asso Ċ import Ġjava . util . ArrayList Ċ Ċ class ĠProduct ListAdapter ( private Ġval Ġproduct ViewModel : ĠProduct ViewModel ): ĠRecyclerView . Adapter < Product ListAdapter . Product ListView Holder >() Ġ{ ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠProduct ListView Holder Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġproduct ListView : ĠView Ġ= ĠLayoutInflater . from ( parent . context ). inflate ( R . layout . recycler _ product _ list _ item , parent , false ) ĊĠĠĠĠĠĠĠ Ġreturn ĠProduct ListView Holder ( product ListView ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Bind ViewHolder ( holder : ĠProduct ListView Holder , Ġposition : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcurrent Product : ĠProduct ? Ġ= Ġproduct ViewModel . get Product At Position ( position ) ĊĠĠĠĠĠĠĠ Ġholder . product Name . text Ġ= Ġcurrent Product ?. name ĊĠĠĠĠĠĠĠ Ġholder . brand Name . text Ġ= Ġcurrent Product ?. brand ĊĠĠĠĠĠĠĠ ĠPic asso . get (). load ( current Product ?. image _ link ). into ( holder . product Thumb ) ĊĊĠĠĠĠĠĠĠ Ġval Ġbundle Ġ= ĠBundle () ĊĠĠĠĠĠĠĠ Ġbundle . putString (" product Name ", Ġcurrent Product ?. name ) ĊĠĠĠĠĠĠĠ Ġbundle . putString (" brand Name ", Ġcurrent Product ?. brand ) ĊĠĠĠĠĠĠĠ Ġbundle . putString (" currency ", Ġcurrent Product ?. price _ sign . toString ()) ĊĠĠĠĠĠĠĠ Ġbundle . putString (" price ", Ġcurrent Product ?. price ) ĊĠĠĠĠĠĠĠ Ġbundle . putString (" rating ", Ġcurrent Product ?. rating . toString ()) ĊĠĠĠĠĠĠĠ Ġbundle . putString (" description ", Ġcurrent Product ?. description ) ĊĠĠĠĠĠĠĠ Ġbundle . putString (" image ", Ġcurrent Product ?. image _ link ) ĊĠĠĠĠĠĠĠ Ġbundle . putString (" rating ", Ġcurrent Product ?. rating . toString ()) ĊĠĠĠĠĠĠĠ Ġbundle . putString ArrayList (" colors ", Ġcurrent Product ?. product _ colors Ġas ĠArrayList < String >) ĊĊĠĠĠĠĠĠĠ Ġholder . product Thumb . setOnClickListener { ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġintent Ġ= ĠIntent ( view . context , ĠProduct Detail Activity :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġintent . put Extras ( bundle ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview . context . startActivity ( intent ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġclass ĠProduct ListView Holder ( var Ġview : ĠView ): ĠRecyclerView . ViewHolder ( view ){ ĊĠĠĠĠĠĠĠ Ġvar Ġproduct Name : ĠTextView Ġ= Ġview . findViewById ( R . id . textView ProductName ) ĊĠĠĠĠĠĠĠ Ġvar Ġbrand Name : ĠTextView Ġ= Ġview . findViewById ( R . id . textView Brand Name ) ĊĠĠĠĠĠĠĠ Ġvar Ġproduct Thumb : ImageView Ġ= Ġview . findViewById ( R . id . imageView Product Image ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠgetItem Count (): ĠInt Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġproduct ViewModel . get Product List Size () !! ĊĠĠĠ Ġ} Ċ } ĊĊ