/** Ċ * Ġ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 . detail . refer endum Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . View Ċ import Ġandroidx . annotation . Color Res Ċ import Ġandroidx . annotation . Drawable Res Ċ import Ġandroidx . annotation . String Res Ċ import Ġandroidx . core . content . Context Compat Ċ import Ġby . kir ich 1 4 0 9 . view binding delegate . view Binding Ċ 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 . ext . set De bounc ed ClickListener Ċ import Ġjp . co . sor am its u . common . util . ext . setImage Tint Ċ import Ġjp . co . sor am its u . feature _ main _ api . di . Main Feature Api Ċ import Ġjp . co . sor am its u . feature _ main _ impl . R Ċ import Ġjp . co . sor am its u . feature _ main _ impl . databinding . Fragment Refer endum Detail Binding Ċ 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 . detail . Base Detail Fragment Ċ import Ġjp . co . sor am its u . feature _ main _ impl . presentation . util . Deadline Formatter Ċ import Ġjp . co . sor am its u . feature _ main _ impl . presentation . util . Vote Bottom Sheet Dialog . V ot able Type Ċ import Ġjp . co . sor am its u . feature _ main _ impl . presentation . util . load Image Ċ import Ġjp . co . sor am its u . feature _ vot able _ api . domain . model . refer endum . Refer endum Ċ import Ġjp . co . sor am its u . feature _ vot able _ api . domain . model . refer endum . Refer endum Status Ċ import Ġjp . co . sor am its u . feature _ wallet _ api . domain . interfaces . Bottom Bar Controller Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠDetail Refer endum Fragment Ġ: ĊĠĠĠ ĠBase Detail Fragment < Detail Refer endum ViewModel >( R . layout . fragment _ refer endum _ detail ) Ġ{ ĊĠĠĠ Ġprivate Ġenum Ġclass ĠV oting Result Style ( ĊĠĠĠĠĠĠĠ Ġ@ Drawable Res Ġval Ġicon Res : ĠInt , ĊĠĠĠĠĠĠĠ Ġ@ Color Res Ġval Ġcolor Res : ĠInt , ĊĠĠĠĠĠĠĠ Ġ@ String Res Ġval Ġstatus Res : ĠInt ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠ ĠAccept ed ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠR . drawable . ic _ thumb _ up _ 2 4 , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠR . color . brand _ sor am its u _ red , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠR . string . refer endum _ support _ title ĊĠĠĠĠĠĠĠ Ġ), ĊĠĠĠĠĠĠĠ ĠReject ed ( R . drawable . ic _ thumb _ down _ 2 4 , ĠR . color . grey , ĠR . string . refer endum _ un support _ title ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġconst Ġval ĠKEY _ REFER END UM _ ID Ġ= Ġ" refer endum _ id " ĊĊĠĠĠĠĠĠĠ Ġfun Ġcreate Bundle ( projectId : ĠString ): ĠBundle Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠBundle (). apply Ġ{ Ġput String ( KEY _ REFER END UM _ ID , ĠprojectId ) Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġoverride Ġlateinit Ġvar Ġdebounce Click Handler : ĠDe bounce Click Handler ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar ĠdateTime Formatter : ĠDateTime Formatter ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdeadline Formatter : ĠDead line Formatter ĊĠĠĠ Ġprivate Ġval Ġbinding Ġby Ġview Binding ( Fragment Refer endum Detail Binding :: bind ) ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĠĠĠĠĠĠĠ Ġ( activity Ġas ĠBottom Bar Controller ). hide Bottom Bar () ĊĊĠĠĠĠĠĠĠ Ġbinding . refer endum Close . setOnClickListener Ġ{ ĠviewModel . back Pressed () Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . refer endum Votes . setOnClickListener Ġ{ ĠviewModel . votes Clicked () Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . refer endum Vote For . set De bounc ed ClickListener ( de bounce Click Handler ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . vote On Refer endum Clicked ( to Support Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . refer endum Vote Again st . set De bounc ed ClickListener ( de bounce Click Handler ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . vote On Refer endum Clicked ( to Support Ġ= Ġfalse ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . refer endum Personal Yes Description . text Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbuild Personal Votes Description ( R . string . refer endum _ support _ title ) ĊĠĠĠĠĠĠĠ Ġbinding . refer endum Personal No Description . text Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbuild Personal Votes Description ( R . string . refer endum _ un support _ title ) ĊĊĠĠĠĠĠĠĠ Ġdeadline Formatter Ġ= ĠDead line Formatter ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . refer endum Deadline Label , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . refer endum Deadline , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠdateTime Formatter ĊĠĠĠĠĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . on Deadline ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġinit Listeners () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Destroy View () Ġ{ ĊĠĠĠĠĠĠĠ Ġdeadline Formatter . release () ĊĠĠĠĠĠĠĠ Ġsuper . on Destroy View () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġinject () Ġ{ ĊĠĠĠĠĠĠĠ ĠFeature Utils . get Feature < Main Feature Component >( require Context (), ĠMain Feature Api :: class . java ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. detail Refer endum Component Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Fragment ( this ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Refer endum Id ( get Refer endum Id ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. inject ( this ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġinit Listeners () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel . votes Formatted LiveData . observe Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . refer endum Votes . text Ġ= Ġit ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠviewModel . refer endum LiveData . observe Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow Refer endum ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠviewModel . show Vote Sheet . observe Ġ{ Ġpayload Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġopen V oting Sheet ( payload . max Allowed Votes , ĠV ot able Type . Refer endum ( payload . to Support )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . vote On Refer endum ( it , Ġpayload . to Support ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġshow Refer endum ( refer endum : ĠRefer endum ) Ġ= Ġwith ( refer endum ) Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding . refer endum Image . load Image ( image Link ) ĊĊĠĠĠĠĠĠĠ Ġdeadline Formatter . set Refer endum ( this ) ĊĊĠĠĠĠĠĠĠ Ġbinding . refer endum Title . text Ġ= Ġname ĊĠĠĠĠĠĠĠ Ġbinding . refer endum Description . text Ġ= Ġdetailed Description ĊĠĠĠĠĠĠĠ Ġbinding . refer endum Vs Line . percentage Ġ= Ġsupporting Percentage ĊĊĠĠĠĠĠĠĠ Ġbinding . refer endum Yes Count . text Ġ= Ġnumbers Formatter . format Integer ( support Votes ) ĊĠĠĠĠĠĠĠ Ġbinding . refer endum No Count . text Ġ= Ġnumbers Formatter . format Integer ( op pose Votes ) ĊĊĠĠĠĠĠĠĠ Ġbinding . refer endum Personal Yes Count . text Ġ= Ġnumbers Formatter . format Integer ( user Support Votes ) ĊĠĠĠĠĠĠĠ Ġbinding . refer endum Personal No Count . text Ġ= Ġnumbers Formatter . format Integer ( user Opp ose Votes ) ĊĊĠĠĠĠĠĠĠ Ġbinding . refer endum Total Votes . text Ġ= Ġnumbers Formatter . format Integer ( total Votes ) ĊĊĠĠĠĠĠĠĠ Ġhandle Refer endum Status ( refer endum ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġhandle Refer endum Status ( refer endum : ĠRefer endum ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( refer endum . status ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRefer endum Status . ACCEPT ED Ġ-> Ġshow Refer endum Result ( V oting Result Style . Accepted ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRefer endum Status . RE JECT ED Ġ-> Ġshow Refer endum Result ( V oting Result Style . Rejected ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRefer endum Status . CREATED Ġ-> Ġshow Refer endum Result ( V oting Result Style . Accepted ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġshow Refer endum Result ( style : ĠV oting Result Style ) Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding . refer endum V oting Group . visibility Ġ= ĠView . GONE ĊĊĠĠĠĠĠĠĠ Ġbinding . refer endum Result Icon . setImage Resource ( style . icon Res ) ĊĠĠĠĠĠĠĠ Ġbinding . refer endum Result Icon . setImage Tint ( style . color Res ) ĊĊĠĠĠĠĠĠĠ Ġbinding . refer endum Result Status . setText ( style . status Res ) ĊĠĠĠĠĠĠĠ Ġbinding . refer endum Result Status . setTextColor ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠContext Compat . getColor ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrequire Context (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstyle . color Res ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġbinding . refer endum Result Group . visibility Ġ= ĠView . VISIBLE ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġbuild Personal Votes Description (@ String Res Ġvote Type Res : ĠInt ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtype Ġ= ĠgetString ( vote Type Res ) ĊĊĠĠĠĠĠĠĠ Ġreturn ĠgetString ( R . string . br ackets _ format , Ġtype ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Refer endum Id () Ġ= Ġrequire Arguments (). getString ( KEY _ REFER END UM _ ID , Ġ"") Ċ } Ċ