package Ġcom . illi arb . t mdb client . modules . home . deleg ates Ċ Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġcom . h ann es dor fm ann . adapter deleg ates 4 . List Deleg ation Adapter Ċ import Ġcom . h ann es dor fm ann . adapter deleg ates 4 . dsl . adapter Delegate View Binding Ċ import Ġcom . illi arb . t mdb client . databinding . Item Trend ing Binding Ċ import Ġcom . illi arb . t mdb client . databinding . Item Trend ing Section Binding Ċ import Ġcom . illi arb . t mdb client . libs . image loader . Crop Options Ċ import Ġcom . illi arb . t mdb client . libs . image loader . clear Ċ import Ġcom . illi arb . t mdb client . libs . ui . R Ċ import Ġcom . illi arb . t mdb client . libs . ui . common . OnClickListener Ċ import Ġcom . illi arb . t mdb client . libs . ui . common . Simple Bundle Store Ċ import Ġcom . illi arb . t mdb client . libs . ui . ext . dim en Ċ import Ġcom . illi arb . t mdb client . libs . ui . widget . recyclerview . Space Decoration Ċ import Ġcom . illi arb . t mdb client . services . t mdb . domain . Movie Ċ import Ġcom . illi arb . t mdb client . services . t mdb . domain . Movie Section Ċ import Ġcom . illi arb . t mdb client . services . t mdb . domain . Trend ing Section Ċ import Ġcom . illi arb . t mdb client . services . t mdb . domain . Trend ing Section . Trend ing Item Ċ import Ġcom . illi arb . t mdb client . util . load T mdb Image Ċ Ċ private Ġconst Ġval ĠKEY _ TRE ND ING _ STATE Ġ= Ġ" trend ing _ state " Ċ Ċ @ Suppress (" Long Method ") Ċ fun Ġtrend ing Section ( ĊĠ Ġbundle Store : ĠSimple Bundle Store , ĊĠ Ġclick Listener : ĠOn ClickListener < Movie > Ċ ) Ġ= Ġadapter Delegate View Binding < Trend ing Section , ĠMovie Section , ĠItem Trend ing Section Binding >( ĊĠ Ġ{ Ġinflater , Ġroot Ġ-> ĠItem Trend ing Section Binding . inflate ( in flater , Ġroot , Ġfalse ) Ġ} Ċ ) Ġ{ ĊĊĠ Ġval Ġadapter Ġ= ĠT rend ing Section Adapter ( click Listener ). apply Ġ{ ĊĠĠĠ Ġstate Rest or ation Policy Ġ= ĠRecyclerView . Adapter . State Rest or ation Policy . PRE VENT _ WHEN _ EMPTY ĊĠ Ġ} ĊĊĠ Ġbinding . item Trend ing Section List . let Ġ{ ĊĠĠĠ Ġit . adapter Ġ= Ġadapter ĊĠĠĠ Ġit . layout Manager Ġ= ĠLinearLayoutManager ( item View . context , ĠLinearLayoutManager . HORIZONTAL , Ġfalse ) ĊĠĠĠ Ġit . addItem Decoration ( ĊĠĠĠĠĠ ĠSpace Decoration . edge Inner Space ( ĊĠĠĠĠĠĠĠ Ġit . dim en ( R . dim en . spacing _ normal ), ĊĠĠĠĠĠĠĠ Ġit . dim en ( R . dim en . spacing _ small ) ĊĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġbind Ġ{ ĊĠĠĠ Ġadapter . items Ġ= Ġitem . items ĊĠĠĠ Ġadapter . notify DataSet Changed () ĊĊĠĠĠ Ġbinding . item Trend ing Section List . layout Manager ?. on Restore InstanceState ( ĊĠĠĠĠĠ Ġbundle Store . get Parcelable ( KEY _ TRE ND ING _ STATE ) ĊĠĠĠ Ġ) ĊĠ Ġ} ĊĊĠ Ġon View Detached From Window Ġ{ ĊĠĠĠ Ġbundle Store . put Parcelable ( ĊĠĠĠĠĠ ĠKEY _ TRE ND ING _ STATE , ĊĠĠĠĠĠ Ġbinding . item Trend ing Section List . layout Manager ?. on Save InstanceState () ĊĠĠĠ Ġ) ĊĠ Ġ} Ċ } Ċ Ċ private Ġclass ĠT rend ing Section Adapter ( click Listener : ĠOn ClickListener < Movie >) Ġ: ĊĠ ĠList Deleg ation Adapter < List < Trend ing Item >>() Ġ{ ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġdeleg ates Manager . add Delegate ( trend ing Delegate ( click Listener )) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġtrend ing Delegate ( click Listener : ĠOn ClickListener < Movie >) Ġ= ĊĠĠĠ Ġadapter Delegate View Binding < Trend ing Item , ĠT rend ing Item , ĠItem Trend ing Binding >( ĊĠĠĠĠĠ Ġ{ Ġinflater , Ġroot Ġ-> ĠItem Trend ing Binding . inflate ( in flater , Ġroot , Ġfalse ) Ġ} ĊĠĠĠ Ġ) Ġ{ ĊĊĠĠĠĠĠ Ġbind Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding . item Trend ing Name . text Ġ= Ġitem . movie . title ĊĊĠĠĠĠĠĠĠ Ġbinding . item Trend ing Image . clear () ĊĠĠĠĠĠĠĠ Ġbinding . item Trend ing Image . load T mdb Image ( item . movie . poster Path ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġcrop ( Crop Options . Circle ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠitemView . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġclick Listener ( item . movie ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }