package Ġcom . tin ac ious design . covid today . adapters Ċ Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . core . os . Configuration Compat Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . bump tech . glide . G lide Ċ import Ġcom . tin ac ious design . covid today . data . Country Ċ import Ġcom . tin ac ious design . covid today . databinding . Country Card Binding Ċ import Ġcom . tin ac ious design . covid today . utils . format Float For Locale Ċ import Ġjava . util .* Ċ Ċ class ĠCount ries Adapter () Ġ: ĠRecyclerView . Adapter < Countries Adapter . Countries ViewHolder >() Ġ{ ĊĠĠĠ Ġvar Ġdata Ġ= Ġmutable ListOf < Country >() ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġview Binding : ĠCountry Card Binding ĊĊĠĠĠ Ġfun Ġupdate Data ( new Data : ĠList < Country >) Ġ{ ĊĠĠĠĠĠĠĠ Ġdata . clear () ĊĠĠĠĠĠĠĠ Ġdata . addAll ( new Data ) ĊĠĠĠĠĠĠĠ Ġnotify DataSet Changed () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠCount ries ViewHolder Ġ{ ĊĠĠĠĠĠĠĠ Ġview Binding Ġ= ĠCountry Card Binding . inflate ( LayoutInflater . from ( parent . context )) ĊĠĠĠĠĠĠĠ Ġval ĠitemView Ġ= Ġview Binding . root ĊĠĠĠĠĠĠĠ Ġreturn ĠCount ries ViewHolder ( item View ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Bind ViewHolder ( view Holder : ĠCount ries ViewHolder , Ġposition : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcountry Ġ= Ġdata [ position ] ĊĠĠĠĠĠĠĠ ĠviewHolder . bind ( country ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠgetItem Count (): ĠInt Ġ= Ġdata . size ĊĊĠĠĠ Ġoverride Ġfun ĠgetItem Id ( position : ĠInt ): ĠLong Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcountry Ġ= Ġdata [ position ] ĊĠĠĠĠĠĠĠ Ġreturn Ġcountry . country Info ._ id . to Long () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠgetItem ViewType ( position : ĠInt ): ĠInt Ġ= Ġposition ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠTAG Ġ= Ġ" Countries Adapter " ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġinner Ġclass ĠCount ries ViewHolder ( item View : ĠView ) Ġ: ĠRecyclerView . ViewHolder ( item View ) Ġ{ ĊĊĠĠĠĠĠĠĠ Ġfun Ġbind ( country : ĠCountry ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġuser Locale : ĠLocale Ġ= ĠConfiguration Compat . get Locales ( item View . resources . configuration )[ 0 ] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview Binding . country Name . text Ġ= Ġcountry . country ĊĊĠĠĠĠĠĠĠĠĠĠĠ ĠG lide . with ( item View . context ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. load ( country . country Info . flag ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. into ( view Binding . country Image ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġview Binding . total Cases . text Ġ= Ġformat Float For Locale ( country . cases , Ġuser Locale ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview Binding . today Cases . text Ġ= Ġformat Float For Locale ( country . today Cases , Ġuser Locale ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview Binding . deaths . text Ġ= Ġformat Float For Locale ( country . deaths , Ġuser Locale ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview Binding . today Death s . text Ġ= Ġformat Float For Locale ( country . today Death s , Ġuser Locale ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview Binding . re covered . text Ġ= Ġformat Float For Locale ( country . re covered , Ġuser Locale ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview Binding . active . text Ġ= Ġformat Float For Locale ( country . active , Ġuser Locale ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview Binding . critical . text Ġ= Ġformat Float For Locale ( country . critical , Ġuser Locale ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview Binding . cases Per One M illion . text Ġ= Ġformat Float For Locale ( country . cases Per One M illion , Ġuser Locale ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġview Binding . deaths Per One M illion . text Ġ= Ġformat Float For Locale ( country . deaths Per One M illion , Ġuser Locale ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } ĊĊĊ