package Ġcom . s mobile . prem ier league . ui . common Ċ Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . databinding . ViewData Binding Ċ import Ġandroidx . recyclerview . widget . Async Differ Config Ċ import Ġandroidx . recyclerview . widget . Diff Util Ċ import Ġandroidx . recyclerview . widget . ListAdapter Ċ import Ġcom . s mobile . prem ier league . App Executors Ċ Ċ /** Ċ Ġ* ĠA Ġgeneric ĠRecyclerView Ġadapter Ġthat Ġuses ĠData ĠBinding Ġ& ĠDiff Util Ċ Ġ* Ċ Ġ* Ġ@ param Ġ< T > ĠType Ġof Ġthe Ġitems Ġin Ġthe Ġlist Ċ Ġ* Ġ@ param Ġ< V > ĠThe Ġtype Ġof Ġthe ĠView Data Binding Ċ Ġ*/ Ċ abstract Ġclass ĠData Bound ListAdapter < T , ĠV Ġ: ĠView Data Binding >( ĊĠĠĠ Ġapp Executors : ĠApp Executors , ĊĠĠĠ Ġdiff Callback : ĠDiff Util . Item Callback < T > Ċ ) Ġ: ĠList Adapter < T , ĠData Bound ViewHolder < V >>( ĊĠĠĠ ĠAsync Differ Config . Builder < T >( diff Callback ) ĊĠĠĠĠĠĠĠ Ġ. setBackground Thread Executor ( app Executors . disk IO ()) ĊĠĠĠĠĠĠĠ Ġ. build () Ċ ) Ġ{ ĊĠĠĠ Ġprivate Ġval Ġview Hold ers : ĠMutable List < Data Bound ViewHolder < ViewData Binding >> Ġ= Ġmutable ListOf () ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ViewHolder ( parent : ĠViewGroup , Ġview Type : ĠInt ): ĠData Bound ViewHolder < V > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbinding Ġ= Ġcreate Binding ( parent ) ĊĠĠĠĠĠĠĠ Ġval ĠviewHolder Ġ= ĠData Bound ViewHolder ( binding ) ĊĠĠĠĠĠĠĠ Ġbinding . lifecycle Owner Ġ= ĠviewHolder ĊĠĠĠĠĠĠĠ ĠviewHolder . mark Created () ĊĠĠĠĠĠĠĠ Ġview Hold ers . add ( view Holder ) ĊĠĠĠĠĠĠĠ Ġreturn ĠviewHolder ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Bind ViewHolder ( holder : ĠData Bound ViewHolder < V >, Ġposition : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġbind ( holder . binding , ĠgetItem ( position )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprotected Ġabstract Ġfun Ġcreate Binding ( parent : ĠViewGroup ): ĠV ĊĊĠĠĠ Ġprotected Ġabstract Ġfun Ġbind ( binding : ĠV , Ġitem : ĠT ) ĊĊĠĠĠ Ġoverride Ġfun Ġon View Attached To Window ( holder : ĠData Bound ViewHolder < V >) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Attached To Window ( holder ) ĊĠĠĠĠĠĠĠ Ġholder . mark Attach () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Detached From Window ( holder : ĠData Bound ViewHolder < V >) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Detached From Window ( holder ) ĊĠĠĠĠĠĠĠ Ġholder . mark Detach () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġset Lifecycle Destroyed () Ġ{ ĊĠĠĠĠĠĠĠ Ġview Hold ers . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . mark Destroyed () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ }