package Ġcom . ch ir ag . covid 1 9 ind ia . adapters Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . databinding . Data Binding Util Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . ch ir ag . covid 1 9 ind ia . R Ċ import Ġcom . ch ir ag . covid 1 9 ind ia . databinding . X Item State Data Binding Ċ import Ġcom . ch ir ag . covid 1 9 ind ia . model . District Data Ċ import Ġcom . ch ir ag . covid 1 9 ind ia . model . State wise Data Ċ import Ġcom . ch ir ag . covid 1 9 ind ia . ui . State Details Activity Ċ import Ġcom . ch ir ag . covid 1 9 ind ia . util . Utils Ċ import Ġjava . util .* Ċ Ċ class ĠState wise Adapter ( private Ġval Ġcontext : ĠContext , Ġprivate Ġvar Ġdata ArrayList : ĠArrayList < State wise Data >, Ġprivate Ġval Ġdistrict DataList : ĠArrayList < District Data >) Ġ: ĠRecyclerView . Adapter < State wise Adapter . ViewHolder >() Ġ{ ĊĠĠĠ Ġoverride Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠViewHolder Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġm Binding : ĠX Item State Data Binding Ġ= ĠData Binding Util . inflate ( LayoutInflater . from ( context ), ĠR . layout . x _ item _ state _ data , Ġparent , Ġfalse ) ĊĠĠĠĠĠĠĠ Ġreturn ĠViewHolder ( m Binding ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Bind ViewHolder ( holder : ĠViewHolder , Ġposition : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġstate wise Data Ġ= Ġdata ArrayList [ position ] ĊĊĠĠĠĠĠĠĠ Ġ// State ĠName ĊĠĠĠĠĠĠĠ Ġholder . m Binder . tv State Name . text Ġ= Ġstate wise Data . state ĊĊĠĠĠĠĠĠĠ Ġ// Confirmed ĠC ases ĊĠĠĠĠĠĠĠ Ġholder . m Binder . tv Confirmed Count . text Ġ= ĠUtils . get Formatted Number ( state wise Data . confirmed !!. toDouble ()) ĊĠĠĠĠĠĠĠ Ġholder . m Binder . tv Confirmed Delta Count . text Ġ= ĠString . format ("[ +% s ]", ĠUtils . get Formatted Number ( state wise Data . delt acon f irmed !!. toDouble ())) ĊĊĠĠĠĠĠĠĠ Ġ// Active ĠC ases ĊĠĠĠĠĠĠĠ Ġholder . m Binder . tv Active Count . text Ġ= ĠUtils . get Formatted Number ( state wise Data . active !!. toDouble ()) ĊĊĠĠĠĠĠĠĠ Ġ// Death ĠC ases ĊĠĠĠĠĠĠĠ Ġholder . m Binder . tv Death Count . text Ġ= ĠUtils . get Formatted Number ( state wise Data . deaths !!. toDouble ()) ĊĠĠĠĠĠĠĠ Ġholder . m Binder . tv Death Delta Count . text Ġ= ĠString . format ("[ +% s ]", ĠUtils . get Formatted Number ( state wise Data . delta deaths !!. toDouble ())) ĊĊĠĠĠĠĠĠĠ Ġ// Re covered ĠC ases ĊĠĠĠĠĠĠĠ Ġholder . m Binder . tv Re covered Count . text Ġ= ĠUtils . get Formatted Number ( state wise Data . re covered !!. toDouble ()) ĊĠĠĠĠĠĠĠ Ġholder . m Binder . tv Re covered Delta Count . text Ġ= ĠString . format ("[ +% s ]", ĠUtils . get Formatted Number ( state wise Data . delt are covered !!. toDouble ())) ĊĊĠĠĠĠĠĠĠ Ġ// Tested ĠC ases ĊĠĠĠĠĠĠĠ Ġholder . m Binder . cv State Cases . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġdistrict DataList . indices ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( state wise Data . state . equals ( district DataList [ i ]. state , Ġignore Case Ġ= Ġtrue )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcontext . startActivity ( Intent ( context , ĠState Details Activity :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. putExtra (" District Data ", Ġdistrict DataList [ i ])) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠgetItem Count (): ĠInt Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġdata ArrayList . size ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġclass ĠViewHolder ( var Ġm Binder : ĠX Item State Data Binding ) Ġ: ĠRecyclerView . ViewHolder ( m Binder . root ) ĊĊĠĠĠ Ġfun Ġfilter List ( filter d Names : ĠArrayList < State wise Data >) Ġ{ ĊĠĠĠĠĠĠĠ Ġdata ArrayList Ġ= Ġfilter d Names ĊĠĠĠĠĠĠĠ Ġnotify DataSet Changed () ĊĠĠĠ Ġ} Ċ Ċ }