package Ġcom . example . application work api Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . ImageView Ċ import Ġandroid . widget . ListView Ċ import Ġandroid . widget . TextView Ċ import Ġandroidx . core . view . get Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . example . application work api . model . Person Ċ import Ġcom . example . application work api . model . Phone Ċ Ċ class ĠPerson Adapter ( ĊĠĠĠ Ġprivate Ġval Ġcontext : Context , ĊĠĠĠ Ġprivate Ġval Ġperson List : List < Person > ĊĠĠĠ Ġ): RecyclerView . Adapter < Person ViewHolder >() Ġ{ ĊĊĠĠĠ Ġlateinit Ġvar Ġre cycler Ph ones : RecyclerView ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠPerson ViewHolder Ġ Ġ= ĠĠ ĠPerson ViewHolder ( LayoutInflater . from ( parent . context ). ĊĠĠĠĠĠĠĠ Ġinf late ( R . layout . person _ card _ item , parent , false )) ĊĊĠĠĠ Ġoverride Ġfun ĠgetItem Count (): ĠInt Ġ= Ġperson List . size ĊĊĊĠĠĠ Ġoverride Ġfun Ġon Bind ViewHolder ( holder : ĠPerson ViewHolder , Ġposition : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġperson : ĠPerson Ġ= Ġperson List [ position ] ĊĠĠĠĠĠĠĠ Ġholder . firstName . text Ġ= Ġperson . firstName ĊĠĠĠĠĠĠĠ Ġholder . lastname . text Ġ= Ġperson . lastName ĊĊĠĠĠĠĠĠĠ Ġval Ġadapter Ġ= ĠPhone Adapter ( context , Ġperson . phones ) ĊĠĠĠĠĠĠĠ Ġre cycler Ph ones Ġ= Ġholder . phones ĊĠĠĠĠĠĠĠ Ġre cycler Ph ones . layout Manager Ġ= ĠLinearLayoutManager ( context ) ĊĠĠĠĠĠĠĠ Ġre cycler Ph ones . adapter Ġ= Ġ Ġadapter ĊĠĠĠĠĠ Ġ} Ċ } Ċ Ċ class ĠPerson ViewHolder ( item View : View ): RecyclerView . ViewHolder ( item View ){ ĊĠĠĠ Ġval ĠfirstName Ġ: ĠTextView Ġ Ġ= ĠitemView . findViewById ( R . id . person _ first _ name ) ĊĠĠĠ Ġval Ġlastname : TextView Ġ= Ġ ĠitemView Ġ. findViewById ( R . id . person _ last _ name ) ĊĠĠĠ Ġval Ġph ones : RecyclerView Ġ= ĠitemView . findViewById ( R . id . recycler _ view _ person _ phones ) Ċ }