/** Ċ * ĠCopyright ĠS or am its u ĠCo ., ĠLtd . ĠAll ĠRights ĠReserved . Ċ * ĠSPDX - License - Identifier : ĠGPL - 3 . 0 Ċ */ Ċ Ċ package Ġjp . co . sor am its u . feature _ main _ impl . presentation . main . projects Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . os . Handler Ċ import Ġandroid . os . Parcelable Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġjp . co . sor am its u . common . base . Base Fragment Ċ import Ġjp . co . sor am its u . common . date . DateTime Formatter Ċ import Ġjp . co . sor am its u . common . di . api . Feature Utils Ċ import Ġjp . co . sor am its u . common . presentation . De bounce Click Handler Ċ import Ġjp . co . sor am its u . common . util . Event Ċ import Ġjp . co . sor am its u . common . util . Event Observer Ċ import Ġjp . co . sor am its u . common . util . Numbers Formatter Ċ import Ġjp . co . sor am its u . common . util . ext . g one Ċ import Ġjp . co . sor am its u . common . util . ext . show Ċ import Ġjp . co . sor am its u . feature _ main _ api . di . Main Feature Api Ċ import Ġjp . co . sor am its u . feature _ main _ impl . di . Main Feature Component Ċ import Ġjp . co . sor am its u . feature _ main _ impl . presentation . main . Main ViewModel Ċ import Ġjp . co . sor am its u . feature _ main _ impl . presentation . main . V ot ables Adapter Ċ import Ġjp . co . sor am its u . feature _ vot able _ api . domain . model . V ot able Ċ import Ġjp . co . sor am its u . feature _ vot able _ api . domain . model . project . Project Ċ import Ġjp . co . sor am its u . feature _ vot able _ api . domain . model . refer endum . Refer endum Ċ import Ġkotlinx . android . synt hetic . main . fragment _ all _ projects . placeholder Ċ import Ġkotlinx . android . synt hetic . main . fragment _ all _ projects . projects _ recyclerview Ċ import Ġjavax . inject . Inject Ċ Ċ abstract Ġclass ĠBase V ot able Fragment Ġ: ĠBase Fragment < Main ViewModel >(), ĠV ot ables Adapter . Project Handler , ĊĠĠĠ ĠV ot ables Adapter . Refer endum Handler Ġ{ ĊĊĠĠĠ Ġprivate Ġval ĠRE CY CL ER VIEW _ UPDATE _ DELAY Ġ= Ġ 3 0 0 L ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġnumbers Formatter : ĠNumbers Formatter ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar ĠdateTime Formatter : ĠDateTime Formatter ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġdebounce Click Handler : ĠDe bounce Click Handler ĊĊĠĠĠ Ġprivate Ġvar Ġlast State : ĠParcel able ? Ġ= Ġnull ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġadapter : ĠV ot ables Adapter ĊĊĠĠĠ Ġabstract Ġfun Ġprovide Projects LiveData ( viewModel : ĠMain ViewModel ): ĠLive Data < List < V ot able >> ĊĠĠĠ Ġabstract Ġfun Ġprovide Projects Res ync Event ( viewModel : ĠMain ViewModel ): ĠLive Data < Event < Unit >> ĊĊĠĠĠ Ġabstract Ġfun Ġupdate Projects ( viewModel : ĠMain ViewModel ) ĊĊĠĠĠ Ġabstract Ġfun Ġprovide Layout Id (): ĠInt ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( ĊĠĠĠĠĠĠĠ Ġinflater : ĠLayoutInflater , ĊĠĠĠĠĠĠĠ Ġcontainer : ĠViewGroup ?, ĊĠĠĠĠĠĠĠ ĠsavedInstanceState : ĠBundle ? ĊĠĠĠ Ġ): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġinflater . inflate ( provide Layout Id (), Ġcontainer , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġinit Views () Ġ{ ĊĠĠĠĠĠĠĠ Ġadapter Ġ= ĠV ot ables Adapter ( numbers Formatter , Ġdebounce Click Handler , Ġthis , Ġthis , ĠdateTime Formatter ) ĊĊĠĠĠĠĠĠĠ Ġprojects _ recyclerview . layout Manager Ġ= ĠLinearLayoutManager ( require Activity ()) ĊĠĠĠĠĠĠĠ Ġprojects _ recyclerview . adapter Ġ= Ġadapter ĊĊĠĠĠĠĠĠĠ Ġlast State ?. let Ġ{ Ġrestore List Position ( it ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġinject () Ġ{ ĊĠĠĠĠĠĠĠ ĠFeature Utils . get Feature < Main Feature Component >( context !! , ĠMain Feature Api :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. projects Component Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Fragment ( parent Fragment !! ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. inject ( this ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġsubscribe ( viewModel : ĠMain ViewModel ) Ġ{ ĊĠĠĠĠĠĠĠ Ġobserve ( provide Projects LiveData ( viewModel ), ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter . submit List ( it ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow Placeholder IfNeeded ( it ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġobserve ( provide Projects Res ync Event ( viewModel ), ĠEvent Observer Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠHandler (). post Delayed ({ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprojects _ recyclerview ?. scrollTo Position ( 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}, ĠRE CY CL ER VIEW _ UPDATE _ DELAY ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ Ġupdate Projects ( viewModel ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Destroy View () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Destroy View () ĊĊĠĠĠĠĠĠĠ Ġ( projects _ recyclerview . layout Manager Ġas ĠLinearLayoutManager ?) ?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlast State Ġ= Ġit . on Save InstanceState () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġrestore List Position ( it : ĠParcel able ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ( projects _ recyclerview . layout Manager Ġas ĠLinearLayoutManager ). on Restore InstanceState ( it ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġshow Placeholder IfNeeded ( it : ĠList < V ot able >) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( it . isEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġplaceholder . show () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprojects _ recyclerview . g one () ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġplaceholder . g one () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprojects _ recyclerview . show () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġproject Vote Clicked ( project : ĠProject ) Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel . vote For Project Clicked ( project ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġproject F avour ite Clicked ( project : ĠProject ) Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel . projects Favorite Clicked ( project ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġproject Clicked ( project : ĠProject ) Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel . project Clicked ( project ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġrefer endum Clicked ( refer endum : ĠRefer endum ) Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel . refer endum Clicked ( refer endum ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġrefer endum Vote For Clicked ( refer endum : ĠRefer endum ) Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel . vote On Refer endum Clicked ( refer endum , Ġto Support Ġ= Ġtrue ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġrefer endum Vote Again st Clicked ( refer endum : ĠRefer endum ) Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel . vote On Refer endum Clicked ( refer endum , Ġto Support Ġ= Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Deadline ( id : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel . on Deadline ( id ) ĊĠĠĠ Ġ} Ċ }