package Ġcom . github . sk ro x . travel ally . ui . main screen . home . adapters Ċ Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . recyclerview . widget . Diff Util Ċ import Ġandroidx . recyclerview . widget . ListAdapter Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . github . sk ro x . travel ally . data . db . entities . Trip Ċ import Ġcom . github . sk ro x . travel ally . databinding . Item Trip Binding Ċ import Ġcom . github . sk ro x . travel ally . databinding . Item Trip Pop ular Binding Ċ import Ġkotlin . random . Random Ċ Ċ class ĠChild Adapter () Ġ: ĊĠĠĠ ĠList Adapter < Trip , ĠChild Adapter . ViewHolder >( Companion ) Ġ{ ĊĊĠĠĠ Ġvar Ġimages Ġ= Ġmutable ListOf < String >(" https :// www . planet ware . com / photos - large / I / it aly - co los se um - day . jpg "," https :// tr ak . in / wp - content / uploads / 2 0 1 0 / 0 4 / T aj M ah al . jpg "," https :// i 0 . wp . com / tri pad visor . wp engine . com / wp - content / uploads / 2 0 1 8 / 1 2 / e iff el - tower - world s - most - popular - attr action . jpeg ? quality = 9 0 & w = 6 2 7 "," https :// s 3 . ind ia . com / travel / wp - content / uploads / 2 0 1 7 / 0 3 / gang tok 1 . jpg "," https :// media . timeout . com / images / 1 0 1 2 4 0 6 6 9 / image . jpg "," https :// www . inter m iles resources . com / iw ov - resources / images / blog / 2 0 - best - places - to - visit - in - s ik kim / Visit - in - S ik kim - Mobile - 4 1 4 x 2 3 3 . jpg ") ĊĊĠĠĠ Ġcompanion Ġobject Ġ: ĠDiff Util . Item Callback < Trip >() Ġ{ ĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġare Items The Same ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġold Item : ĠTrip , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnew Item : ĠTrip ĊĠĠĠĠĠĠĠ Ġ): ĠBoolean Ġ= Ġold Item Ġ=== Ġnew Item ĊĊĠĠĠĠĠĠĠ Ġoverride Ġfun Ġare Contents The Same ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġold Item : ĠTrip , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnew Item : ĠTrip ĊĠĠĠĠĠĠĠ Ġ): ĠBoolean Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġold Item . id Ġ== Ġnew Item . id ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠViewHolder Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlayout Inflater Ġ= ĠLayoutInflater . from ( parent . context ) ĊĠĠĠĠĠĠĠ Ġval Ġbinding Ġ= ĠItem Trip Pop ular Binding . inflate ( layout Inflater ) ĊĠĠĠĠĠĠĠ Ġreturn ĠViewHolder ( binding ) ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġoverride Ġfun Ġon Bind ViewHolder ( holder : ĠViewHolder , Ġposition : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcurrent Trip Ġ= ĠgetItem ( position ) ĊĠĠĠĠĠĠĠ Ġval Ġrand Ġ= ĠRandom ( System . nano Time ()) ĊĠĠĠĠĠĠĠ Ġcurrent Trip . image Ġ= Ġimages [( 0 .. 5 ). random ( rand )] ĊĠĠĠĠĠĠĠ Ġholder . binding . trip Ġ= Ġcurrent Trip ĊĠĠĠĠĠĠĠ Ġholder . binding . execute Pending Bindings () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġinner Ġclass ĠViewHolder ( val Ġbinding : ĠItem Trip Pop ular Binding ) Ġ: ĠRecyclerView . ViewHolder ( binding . root ) Ċ }