package Ġcom . f riday tech . dex . presentation . exchange . confirm Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . View Ċ import Ġandroidx . fragment . app . FragmentManager Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġandroidx . lifecycle . ViewModel Providers Ċ import Ġcom . f riday tech . dex . R Ċ import Ġcom . f riday tech . dex . presentation . dialogs . Base Dialog Ċ import Ġcom . f riday tech . dex . presentation . widgets . click . set Single ClickListener Ċ import Ġcom . f riday tech . dex . utils . ui . to Display Format Ċ import Ġcom . f riday tech . dex . utils . visible Ċ import Ġkotlinx . android . synt hetic . main . dialog _ confirm _ exchange .* Ċ import Ġjava . math . BigDecimal Ċ Ċ class ĠExchange Confirm Dialog Ġ: ĠBase Dialog ( R . layout . dialog _ confirm _ exchange ) Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar ĠviewModel : ĠExchange Confirm ViewModel ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġinfo : ĠExchange Confirm Info ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠviewModel Ġ= ĠViewModel Providers . of ( this ). get ( Exchange Confirm ViewModel :: class . java ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . init ( info ) ĊĊĠĠĠĠĠĠĠ ĠviewModel . view State . observe ( this , ĠObserver Ġ{ Ġrefresh State ( it ) Ġ}) ĊĊĠĠĠĠĠĠĠ ĠviewModel . fee Info . observe ( this , ĠObserver Ġ{ Ġfee Info Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( fee Info . amount Ġ> ĠBigDecimal . ZERO ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexchange _ confirm _ fee ?. visible Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexchange _ confirm _ fee ?. set Coin ( fee Info . coin Code , Ġfee Info . amount , Ġfalse ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġexchange _ confirm _ fee ?. visible Ġ= Ġfalse ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ ĠviewModel . processing Time . observe ( this , ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġexchange _ confirm _ processing _ time ?. set Millis ( it ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠĠĠĠĠ ĠviewModel . dismiss Event . observe ( this , ĠObserver Ġ{ Ġdismiss () Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on View Created ( view , ĠsavedInstanceState ) ĊĊĠĠĠĠĠĠĠ Ġexchange _ confirm . set Single ClickListener Ġ{ ĠviewModel . on Confirm Click () Ġ} ĊĊĠĠĠĠĠĠĠ Ġexchange _ confirm _ lifetime _ info . visible Ġ= Ġinfo . show Life Time Info ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġrefresh State ( state : ĠExchange Confirm ViewModel . ViewState ) Ġ{ ĊĠĠĠĠĠĠĠ Ġexchange _ confirm _ from _ coin ?. bind ( state . from Coin . code ) ĊĠĠĠĠĠĠĠ Ġexchange _ confirm _ to _ coin ?. bind ( state . to Coin . code ) ĊĠĠĠĠĠĠĠ Ġexchange _ confirm _ send _ hint ?. text Ġ= Ġ" Sell Ġ${ state . from Coin . code }" ĊĠĠĠĠĠĠĠ Ġexchange _ confirm _ receive _ hint ?. text Ġ= Ġ" Buy Ġ${ state . to Coin . code }" ĊĠĠĠĠĠĠĠ Ġexchange _ confirm _ send _ amount ?. text Ġ= Ġ"${ state . send Amount . to Display Format () }" ĊĠĠĠĠĠĠĠ Ġexchange _ confirm _ receive _ amount ?. text Ġ= Ġ"${ state . receive Amount . to Display Format () }" ĊĊĠĠĠĠĠĠĠ Ġexchange _ confirm _ price ?. set Coin ( state . to Coin . code , Ġstate . price ) ĊĠĠĠĠĠĠĠ Ġexchange _ confirm _ price ?. visible Ġ= Ġstate . price Ġ!= ĠBigDecimal . ZERO ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġfun Ġopen ( fragment Manager : ĠFragment Manager , Ġinfo : ĠExchange Confirm Info ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġfragment Ġ= ĠExchange Confirm Dialog () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġfragment . info Ġ= Ġinfo ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġfragment . show ( fragment Manager , Ġ" exchange _ confirm ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ