package Ġcom . coin ninja . coin keeper . ui . lightning . broadcast Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . View Ċ import Ġandroid . widget . Button Ċ import Ġandroid . widget . TextView Ċ import Ġandroid . widget . Toast Ċ import Ġandroidx . core . content . res . Resources Compat Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġapp . coin ninja . cn . th under d ome . model . Ledger Invoice Ċ import Ġapp . drop bit . commons . util . isNotNull Ċ import Ġcom . coin ninja . android . helpers . g one Ċ import Ġcom . coin ninja . android . helpers . show Ċ import Ġcom . coin ninja . android . helpers . style As Lightning Ċ import Ġcom . coin ninja . coin keeper . R Ċ import Ġcom . coin ninja . coin keeper . cn . transaction . Fund ing ViewModel Provider Ċ import Ġcom . coin ninja . coin keeper . cn . transaction . notification . Fund ing ViewModel Ċ import Ġcom . coin ninja . coin keeper . model . Payment Holder Ċ import Ġcom . coin ninja . coin keeper . ui . base . Base Activity Ċ import Ġcom . coin ninja . coin keeper . util . Drop bit Intent s Ċ import Ġcom . coin ninja . coin keeper . view . progress . Sending Progress View Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠBroadcast Lightning Payment Activity Ġ: ĠBase Activity () Ġ{ ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġfunding ViewModel Provider : ĠFund ing ViewModel Provider ĊĊĠĠĠ Ġlateinit Ġvar Ġfunding ViewModel : ĠFund ing ViewModel ĊĠĠĠ Ġlateinit Ġvar Ġpayment Holder : ĠPayment Holder ĊĊĠĠĠ Ġval Ġpaid Invoice Complete Observer : ĠObserver < Ledger Invoice > Ġ= ĠObserver Ġ{ Ġinvoice Ġ-> ĊĠĠĠĠĠĠĠ Ġif Ġ( invoice . value Ġ> Ġ 0 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow Success () ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow Failure () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġsending Progress View : ĠSending Progress View Ġget () Ġ= ĠfindViewById ( R . id . broadcast _ sending _ progress ) ĊĠĠĠ Ġval Ġsending Progress Label : ĠTextView Ġget () Ġ= ĠfindViewById ( R . id . broadcast _ sending _ progress _ label ) ĊĠĠĠ Ġval Ġtransaction Id Label : ĠTextView Ġget () Ġ= ĠfindViewById ( R . id . transaction _ id _ label ) ĊĠĠĠ Ġval Ġtransaction Id Link : ĠTextView Ġget () Ġ= ĠfindViewById ( R . id . transaction _ id _ link ) ĊĠĠĠ Ġval Ġtransaction Action Btn : ĠButton Ġget () Ġ= ĠfindViewById ( R . id . transaction _ complete _ action _ button ) ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( R . layout . activity _ broadcast ) ĊĠĠĠĠĠĠĠ Ġpayment Data From Creation () ĊĠĠĠĠĠĠĠ Ġfunding ViewModel Ġ= Ġfunding ViewModel Provider . provide ( this ) ĊĠĠĠĠĠĠĠ Ġretry () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Resume () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Resume () ĊĠĠĠĠĠĠĠ Ġfunding ViewModel . ledger Invoice . observe ( this , Ġpaid Invoice Complete Observer ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Pause () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Pause () ĊĠĠĠĠĠĠĠ Ġfunding ViewModel . ledger Invoice . remove Observer ( paid Invoice Complete Observer ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġclear () Ġ{ ĊĠĠĠĠĠĠĠ Ġsending Progress View . reset View () ĊĠĠĠĠĠĠĠ Ġsending Progress Label . show () ĊĠĠĠĠĠĠĠ Ġsending Progress Label . text Ġ= Ġresources . getText ( R . string . broadcast _ sent _ label ) ĊĠĠĠĠĠĠĠ Ġtransaction Id Label . g one () ĊĠĠĠĠĠĠĠ Ġtransaction Id Link . g one () ĊĠĠĠĠĠĠĠ Ġtransaction Action Btn . g one () ĊĠĠĠĠĠĠĠ Ġtransaction Action Btn . setOnClickListener Ġ{} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġshow Success () Ġ{ ĊĠĠĠĠĠĠĠ Ġsending Progress View . progress Ġ= Ġ 1 0 0 ĊĠĠĠĠĠĠĠ Ġsending Progress View . complete Success () ĊĠĠĠĠĠĠĠ Ġsending Progress Label . show () ĊĠĠĠĠĠĠĠ Ġsending Progress Label . text Ġ= Ġresources . getText ( R . string . broadcast _ sent _ label ) ĊĠĠĠĠĠĠĠ Ġtransaction Id Link . text Ġ= Ġpayment Holder . request Invoice ?. encoded Ġ?: Ġ"" ĊĠĠĠĠĠĠĠ Ġtransaction Id Link . show () ĊĠĠĠĠĠĠĠ Ġtransaction Action Btn . show () ĊĠĠĠĠĠĠĠ Ġtransaction Action Btn . text Ġ= Ġresources . getText ( R . string . broadcast _ sent _ ok ) ĊĠĠĠĠĠĠĠ Ġtransaction Action Btn . style As Lightning () ĊĠĠĠĠĠĠĠ Ġtransaction Action Btn . setOnClickListener Ġ{ Ġactivity Navigation Util . navigate To Home ( this ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġinternal Ġfun Ġshow Failure () Ġ{ ĊĠĠĠĠĠĠĠ Ġsending Progress View . progress Ġ= Ġ 1 0 0 ĊĠĠĠĠĠĠĠ Ġsending Progress View . complete Fail () ĊĠĠĠĠĠĠĠ Ġsending Progress Label . visibility Ġ= ĠView . VISIBLE ĊĠĠĠĠĠĠĠ Ġsending Progress Label . text Ġ= Ġresources . getText ( R . string . broadcast _ sent _ label ) ĊĠĠĠĠĠĠĠ Ġtransaction Action Btn . visibility Ġ= ĠView . VISIBLE ĊĠĠĠĠĠĠĠ Ġtransaction Action Btn . text Ġ= Ġresources . getText ( R . string . broadcast _ sent _ try _ again ) ĊĠĠĠĠĠĠĠ Ġtransaction Action Btn . background Ġ= ĠResources Compat . get Drawable ( resources , ĠR . drawable . error _ button , Ġtheme ) ĊĠĠĠĠĠĠĠ Ġtransaction Action Btn . setOnClickListener Ġ{ Ġretry () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġretry () Ġ{ ĊĠĠĠĠĠĠĠ Ġclear () ĊĠĠĠĠĠĠĠ Ġpayment Holder . request Invoice ?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfunding ViewModel . perform Lightning Payment ( it . encoded , Ġit . num Sat osh is ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġpayment Data From Creation () Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( intent . has Extra ( Drop bit Intent s . EXTRA _ PAYMENT _ HOLDER )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpayment Holder Ġ= Ġintent . get Parcelable Extra ( Drop bit Intent s . EXTRA _ PAYMENT _ HOLDER ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpayment Holder Ġ= ĠPayment Holder () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠToast . makeText ( this , Ġ" Missing ĠPayment ĠData ", ĠToast . LENGTH _ LONG ). show () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfinish () ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġif Ġ(! payment Holder . request Invoice . isNotNull () Ġ|| Ġpayment Holder . request Invoice ?. encoded . isNull OrEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠToast . makeText ( this , Ġ" Missing ĠPayment ĠData ", ĠToast . LENGTH _ LONG ). show () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfinish () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ } Ċ