package Ġit . il ker . repeat card . ui . results Ċ Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . TextView Ċ import Ġandroidx . card view . widget . Card View Ċ import Ġandroidx . recyclerview . widget . Diff Util Ċ import Ġandroidx . recyclerview . widget . ListAdapter Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġit . il ker . repeat card . R Ċ import Ġit . il ker . repeat card . models . question . Question Ċ Ċ class ĠResults Adapter ( private Ġval Ġclick Listener : ĠResult Listener ) Ġ: ĠList Adapter < Question , ĠResults ViewHolder >( Question Diff Util ()) Ġ{ ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠResults ViewHolder Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlayout Inflater Ġ= ĠLayoutInflater . from ( parent . context ) ĊĠĠĠĠĠĠĠ Ġval Ġcell For Row Ġ= Ġlayout Inflater . inflate ( R . layout . result _ row , Ġparent , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġreturn ĠResults ViewHolder ( cell For Row ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Bind ViewHolder ( holder : ĠResults ViewHolder , Ġposition : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġquestion Ġ= ĠgetItem ( holder . adapter Position ) ĊĠĠĠĠĠĠĠ Ġholder . question Number . text Ġ= Ġ( holder . adapter Position Ġ+ Ġ 1 ). toString () ĊĠĠĠĠĠĠĠ Ġholder . question Text . text Ġ= Ġquestion . correct Answer ĊĠĠĠĠĠĠĠ Ġholder . answer Text . text Ġ= Ġif Ġ( question . selected Answer . isNull OrEmpty ()) Ġ" No Ġanswer " Ġelse Ġquestion . selected Answer ĊĊĠĠĠĠĠĠĠ Ġholder . card . setOnClickListener Ġ{ Ġclick Listener . show Result Details ( question ) Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ class ĠResults ViewHolder ( view : ĠView ) Ġ: ĠRecyclerView . ViewHolder ( view ) Ġ{ ĊĠĠĠ Ġval Ġcard : ĠCard View Ġ= Ġview . findViewById ( R . id . card Result Row ) ĊĠĠĠ Ġval Ġquestion Number : ĠTextView Ġ= Ġview . findViewById ( R . id . question Number Result Row ) ĊĠĠĠ Ġval Ġquestion Text : ĠTextView Ġ= Ġview . findViewById ( R . id . question Text Result Row ) ĊĠĠĠ Ġval Ġanswer Text : ĠTextView Ġ= Ġview . findViewById ( R . id . answer Text Result Row ) Ċ } Ċ Ċ interface ĠResult Listener Ġ{ ĊĠĠĠ Ġfun Ġshow Result Details ( question : ĠQuestion ) Ċ } Ċ Ċ class ĠQuestion Diff Util Ġ: ĠDiff Util . Item Callback < Question >() Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġare Items The Same ( old Item : ĠQuestion , Ġnew Item : ĠQuestion ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġold Item Ġ== Ġnew Item ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġare Contents The Same ( old Item : ĠQuestion , Ġnew Item : ĠQuestion ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġold Item Ġ== Ġnew Item ĊĠĠĠ Ġ} Ċ } Ċ