package Ġcom . robot nec . budget . ref actored . screens . home Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġandroidx . navigation . fragment . find Nav Controller Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġcom . robot nec . budget . R Ċ import Ġcom . robot nec . budget . app . adapters . Home Header Ċ import Ġcom . robot nec . budget . app . adapters . support . Header Adapter Ċ import Ġcom . robot nec . budget . app . adapters . transaction . Transactions Adapter Ċ import Ġcom . robot nec . budget . core . navigator . Navigator Ċ import Ġcom . robot nec . budget . ref actored . di . helpers . Injectable Ċ import Ġcom . robot nec . budget . ref actored . extensions . get ViewModel Ċ import Ġcom . robot nec . budget . ref actored . screens . Base Fragment Ċ import Ġkotlinx . android . synt hetic . main . fragment _ home .* Ċ import Ġjavax . inject . Inject Ċ Ċ /** Ċ Ġ* Ġ@ author Ġz ak Ġz ak @ swing pulse . com > Ċ Ġ*/ Ċ @ Injectable Ċ class ĠHome Fragment Ġ: ĠBase Fragment () Ġ{ ĊĠĠĠ Ġoverride Ġval Ġlayout Id Ġ= ĠR . layout . fragment _ home ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġheader Adapter : ĠHeader Adapter ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġtransactions Adapter : ĠTransactions Adapter ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġhome Header : ĠHome Header ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġnavigator : ĠNavigator ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar ĠviewModel Factory : ĠViewModel Provider . Factory ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠviewModel : ĠHome ViewModel ĊĊĠĠĠ Ġoverride Ġfun Ġinit View ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġinit RecyclerView () ĊĊĠĠĠĠĠĠĠ ĠviewModel Ġ= Ġget ViewModel ( viewModel Factory , ĠHome ViewModel :: class ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . get Accounts (). observe ( this , ĠObserver Ġ{ Ġaccounts Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhome Header . update ( accounts ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ ĠviewModel . get Ag gregated Transactions (). observe ( this , ĠObserver Ġ{ Ġaggregation Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtransactions Adapter . update ( aggregation ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġheader Adapter . notify DataSet Changed () ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġfab . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnavigator . open Add Transaction Screen ( find Nav Controller ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġinit RecyclerView () Ġ{ ĊĠĠĠĠĠĠĠ Ġtransactions Adapter Ġ= ĠTransactions Adapter () ĊĠĠĠĠĠĠĠ Ġhome Header Ġ= ĠHome Header () ĊĠĠĠĠĠĠĠ Ġheader Adapter Ġ= ĠHeader Adapter ( transactions Adapter , Ġhome Header ) ĊĊĠĠĠĠĠĠĠ Ġhome RecyclerView . apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlayout Manager Ġ= ĠLinearLayoutManager ( context ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter Ġ= ĠHeader Adapter ( transactions Adapter , Ġhome Header ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Has Fixed Size ( true ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ