package Ġch . d re ip ol . rez hy cle . view Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . ViewGroup Ċ import Ġch . d re ip ol . d re im ulti platform . redux kotlin . root Dispatch Ċ import Ġch . d re ip ol . multi platform . redux sample . shared . redux . thunk . add Or Remove Notification Thunk Ċ import Ġch . d re ip ol . multi platform . redux sample . shared . ui . Dis posal Calendar Entry Ċ import Ġch . d re ip ol . multi platform . redux sample . shared . ui . Dis posal Calendar Month Ċ import Ġch . d re ip ol . rez hy cle . databinding . View Calendar Header Binding Ċ import Ġch . d re ip ol . rez hy cle . databinding . View Dis posal Group Item Binding Ċ import Ġch . d re ip ol . rez hy cle . databinding . View Dis posal ListItem Binding Ċ import Ġch . d re ip ol . rez hy cle . utils . get Drawable Identifier Ċ import Ġch . d re ip ol . rez hy cle . utils . getString Ċ import Ġcom . github . d re ip ol . d re id roid . components . Group edList Adapter Ċ import Ġcom . github . d re ip ol . d re id roid . utils . View Utils Ċ Ċ class ĠCalendar ListAdapter ( ĊĠĠĠ Ġvar Ġcalendar Header Model : ĠCalendar Header Model , ĊĠĠĠ Ġvar Ġdis posal Calendar Entry : ĠList < Dis posal Calendar Month >, ĊĠĠĠ Ġprivate Ġval Ġcontext : ĠContext Ċ ) Ġ: ĠGroup edList Adapter < Dis posal Calendar Entry , ĠString , ĠString , ĠView Dis posal Group Item Binding , ĠView Dis posal ListItem Binding >() Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠCAL END AR _ HEADER _ VIEW _ TYPE Ġ= Ġ 3 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠGroup edList ViewHolder Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( view Type Ġ== ĠCAL END AR _ HEADER _ VIEW _ TYPE ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠGroup edList ViewHolder ( View Calendar Header Binding . inflate ( LayoutInflater . from ( context ), Ġparent , Ġfalse )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġsuper . onCreate ViewHolder ( parent , Ġview Type ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Bind ViewHolder ( holder : ĠGroup edList ViewHolder , Ġposition : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( position Ġ== Ġ 0 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbinding Ġ= Ġholder . binding Ġas ĠView Calendar Header Binding ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconfigure Calendar Header Binding ( binding ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġsuper . on Bind ViewHolder ( holder , Ġposition Ġ- Ġ 1 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠgetItem Count (): ĠInt Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġsuper . getItem Count () Ġ+ Ġ 1 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠgetItem ViewType ( position : ĠInt ): ĠInt Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( position Ġ== Ġ 0 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠCAL END AR _ HEADER _ VIEW _ TYPE ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġsuper . getItem ViewType ( position Ġ- Ġ 1 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Sort Comp erator (): ĠComparator < Dis posal Calendar Entry > Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Ġkeep Ġorder ĊĠĠĠĠĠĠĠ Ġreturn ĠComparator Ġ{ Ġ_, Ġ_ Ġ-> Ġ 0 Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠgetData (): ĠList < Dis posal Calendar Entry > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġdis posal Calendar Entry . flatMap Ġ{ Ġit . dis posal Calendar Entries Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget GroupBy Property ( data Model : ĠDis posal Calendar Entry ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġdis posal Calendar Entry . first Ġ{ Ġit . dis posal Calendar Entries . contains ( data Model ) Ġ}. formatted Header ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Header Model ( data Model : ĠDis posal Calendar Entry ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġdis posal Calendar Entry . first Ġ{ Ġit . dis posal Calendar Entries . contains ( data Model ) Ġ}. formatted Header ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġcreate Header Binding ( parent : ĠViewGroup ): ĠView Dis posal Group Item Binding Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠView Dis posal Group Item Binding . inflate ( LayoutInflater . from ( context ), Ġparent , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġcreate Data Item Binding ( parent : ĠViewGroup ): ĠView Dis posal ListItem Binding Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠView Dis posal ListItem Binding . inflate ( LayoutInflater . from ( context ), Ġparent , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġconfigure Header Binding ( binding : ĠView Dis posal Group Item Binding , Ġmodel : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding . text . text Ġ= Ġmodel ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġconfigure Data Item Binding ( binding : ĠView Dis posal ListItem Binding , Ġmodel : ĠDis posal Calendar Entry ) Ġ{ ĊĠĠĠĠĠĠĠ ĠView Utils . use Touch Down Listener ( binding . bell , Ġbinding . item Container ) ĊĠĠĠĠĠĠĠ Ġbinding . bell . setOnClickListener Ġ{ Ġroot Dispatch ( add Or Remove Notification Thunk ( model . dis posal . dis posal Type )) Ġ} ĊĠĠĠĠĠĠĠ Ġbinding . bell . setImage Resource ( context . get Drawable Identifier ( model . notification Icon Id )) ĊĠĠĠĠĠĠĠ Ġbinding . date . text Ġ= Ġmodel . build Time String Ġ{ Ġcontext . getString ( it ) Ġ} ĊĠĠĠĠĠĠĠ Ġbinding . icon . setImage Resource ( context . get Drawable Identifier ( model . dis posal . dis posal Type . icon Id )) ĊĠĠĠĠĠĠĠ Ġbinding . text . text Ġ= Ġcontext . getString ( model . dis posal . dis posal Type . translation Key ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġconfigure Calendar Header Binding ( binding : ĠView Calendar Header Binding ) Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding . title . text Ġ= Ġcalendar Header Model . title ĊĠĠĠĠĠĠĠ Ġbinding . next Dis posals . adapter Ġ= Ġcalendar Header Model . adapter ĊĠĠĠ Ġ} Ċ } Ċ Ċ data Ġclass ĠCalendar Header Model ( val Ġtitle : ĠString , Ġval Ġadapter : ĠNext Dis posal ListAdapter )