package Ġorg . step ik . android . view . course _ purchase . delegate Ċ Ċ import Ġandroid . graphics . Port er D uff Ċ import Ġandroid . graphics . drawable . Animation Drawable Ċ import Ġandroid . view . View Ċ import Ġandroidx . appcompat . content . res . AppCompat Resources Ċ import Ġandroidx . core . graphics . drawable . Drawable Compat Ċ import Ġandroidx . core . view . is G one Ċ import Ġandroidx . core . view . isVisible Ċ import Ġcom . google . android . material . button . Material Button Ċ import Ġorg . step ic . d roid . R Ċ import Ġorg . step ic . d roid . databinding . Bottom Sheet Dialog Course Purchase Binding Ċ import Ġorg . step ic . d roid . util . resolve Color Attribute Ċ import Ġorg . step ik . android . presentation . course _ purchase . Course Purchase Feature Ċ import Ġorg . step ik . android . presentation . course _ purchase . model . Course Purchase Data Ċ import Ġorg . step ik . android . view . course . mapper . Display Price Mapper Ċ import Ġru . nob ird . android . view . base . ui . extension . get Drawable Compat Ċ Ċ class ĠBu y Action View Delegate ( ĊĠĠĠ Ġcourse Purchase Binding : ĠBottom Sheet Dialog Course Purchase Binding , ĊĠĠĠ Ġprivate Ġval Ġcourse Purchase Data : ĠCourse Purchase Data , ĊĠĠĠ Ġprivate Ġval Ġdisplay Price Mapper : ĠDisplay Price Mapper , ĊĠĠĠ Ġlaunch Purchase Flow Action : Ġ() Ġ-> ĠUnit , ĊĠĠĠ Ġlaunch Start Study ing : Ġ() Ġ-> ĠUnit , ĊĠĠĠ Ġlaunch Restore Action : Ġ() Ġ-> ĠUnit , ĊĠĠĠ Ġclose Dialog : Ġ() Ġ-> ĠUnit Ċ ) Ġ{ ĊĠĠĠ Ġprivate Ġval Ġcontext Ġ= Ġcourse Purchase Binding . root . context ĊĠĠĠ Ġprivate Ġval Ġcourse Purchase Buy Action Green Ġ= Ġcourse Purchase Binding . course Purchase Buy Action Green ĊĠĠĠ Ġprivate Ġval Ġcourse Purchase Buy Action V io let Ġ= Ġcourse Purchase Binding . course Purchase Buy Action V io let ĊĠĠĠ Ġprivate Ġval Ġcourse Purchase Terminal Action Ġ= Ġcourse Purchase Binding . course Purchase Terminal Action ĊĠĠĠ Ġprivate Ġval Ġcourse Purchase Payment Icon Ġ= Ġcourse Purchase Binding . course Purchase Payment Icon ĊĠĠĠ Ġprivate Ġval Ġcourse Purchase Payment Title Ġ= Ġcourse Purchase Binding . course Purchase Payment Title ĊĠĠĠ Ġprivate Ġval Ġcourse Purchase Payment Failure Feedback Ġ= Ġcourse Purchase Binding . course Purchase Payment Failure Feedback ĊĠĠĠ Ġprivate Ġval Ġcourse Purchase Payment Pending Feedback Ġ= Ġcourse Purchase Binding . course Purchase Payment Pending Feedback ĊĠĠĠ Ġprivate Ġval Ġcourse Purchase Com mission Notice Ġ= Ġcourse Purchase Binding . course Purchase Com mission Notice ĊĊĠĠĠ Ġprivate Ġvar Ġpayment State : ĠCourse Purchase Feature . Payment State Ġ= ĠCourse Purchase Feature . Payment State . Idle ĊĊĠĠĠ Ġprivate Ġval Ġidle ClickListener Ġ= ĠView . OnClickListener Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( payment State Ġis ĠCourse Purchase Feature . Payment State . Idle ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Purchase Flow Action () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġcourse Purchase Buy Action Green . setOnClickListener ( idle ClickListener ) ĊĠĠĠĠĠĠĠ Ġcourse Purchase Buy Action V io let . setOnClickListener ( idle ClickListener ) ĊĠĠĠĠĠĠĠ Ġcourse Purchase Terminal Action . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhen Ġ( payment State ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCourse Purchase Feature . Payment State . Payment Success Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Start Study ing () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCourse Purchase Feature . Payment State . Payment Failure Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Restore Action () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCourse Purchase Feature . Payment State . Payment Pending Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġclose Dialog () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġ{} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġrender ( state : ĠCourse Purchase Feature . State . Content ) Ġ{ ĊĠĠĠĠĠĠĠ Ġthis . payment State Ġ= Ġstate . payment State ĊĠĠĠĠĠĠĠ Ġval Ġis Terminal State Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstate . payment State Ġis ĠCourse Purchase Feature . Payment State . Payment Failure Ġ|| ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstate . payment State Ġis ĠCourse Purchase Feature . Payment State . Payment Pending Ġ|| ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstate . payment State Ġis ĠCourse Purchase Feature . Payment State . Payment Success ĊĊĠĠĠĠĠĠĠ Ġcourse Purchase Payment Title . isVisible Ġ= Ġis Terminal State ĊĠĠĠĠĠĠĠ Ġcourse Purchase Payment Icon . isVisible Ġ= Ġis Terminal State ĊĠĠĠĠĠĠĠ Ġcourse Purchase Payment Failure Feedback . isVisible Ġ= Ġstate . payment State Ġis ĠCourse Purchase Feature . Payment State . Payment Failure ĊĠĠĠĠĠĠĠ Ġcourse Purchase Payment Pending Feedback . isVisible Ġ= Ġstate . payment State Ġis ĠCourse Purchase Feature . Payment State . Payment Pending ĊĠĠĠĠĠĠĠ Ġcourse Purchase Com mission Notice . is G one Ġ= Ġis Terminal State ĊĊĠĠĠĠĠĠĠ Ġcourse Purchase Buy Action Green . isVisible Ġ= Ġstate . promo Code State Ġ! is ĠCourse Purchase Feature . Promo Code State . Valid Ġ&& Ġ! is Terminal State ĊĠĠĠĠĠĠĠ Ġcourse Purchase Buy Action V io let . isVisible Ġ= Ġstate . promo Code State Ġis ĠCourse Purchase Feature . Promo Code State . Valid Ġ&& Ġ! is Terminal State ĊĠĠĠĠĠĠĠ Ġcourse Purchase Terminal Action . isVisible Ġ= Ġis Terminal State ĊĠĠĠĠĠĠĠ Ġrender Idle Button ( state , Ġcourse Purchase Buy Action Green ) ĊĠĠĠĠĠĠĠ Ġrender Idle Button ( state , Ġcourse Purchase Buy Action V io let ) ĊĠĠĠĠĠĠĠ Ġrender Terminal Button ( state ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġrender Idle Button ( state : ĠCourse Purchase Feature . State . Content , Ġcourse Purchase Buy Action : ĠMaterial Button ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( state . payment State ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCourse Purchase Feature . Payment State . Idle Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Buy Action . icon Ġ= Ġnull ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġcourse Display Price Ġ= Ġcourse Purchase Data . course . display Price ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Buy Action . text Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( course Display Price Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( state . promo Code State Ġis ĠCourse Purchase Feature . Promo Code State . Valid Ġ&& ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstate . promo Code State . promo Code Sku . light Sku Ġ!= Ġnull ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdisplay Price Mapper . map To Discount ed Display Price Sp anned String ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Data . primary Sku . price , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstate . promo Code State . promo Code Sku . light Sku . price ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcontext . getString ( R . string . course _ payments _ purchase _ in _ web _ with _ price , Ġcourse Purchase Data . primary Sku . price ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcontext . getString ( R . string . course _ payments _ purchase _ in _ web ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCourse Purchase Feature . Payment State . Processing Initial Check , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCourse Purchase Feature . Payment State . Processing Billing Payment , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCourse Purchase Feature . Payment State . Processing Consume Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġevaluation Drawable Ġ= ĠAnimation Drawable () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġevaluation Drawable . add Frame ( context . get Drawable Compat ( R . drawable . ic _ step _ quiz _ evaluation _ frame _ 1 ), Ġ 2 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġevaluation Drawable . add Frame ( context . get Drawable Compat ( R . drawable . ic _ step _ quiz _ evaluation _ frame _ 2 ), Ġ 2 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġevaluation Drawable . add Frame ( context . get Drawable Compat ( R . drawable . ic _ step _ quiz _ evaluation _ frame _ 3 ), Ġ 2 0 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġevaluation Drawable . is One Shot Ġ= Ġfalse ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Buy Action . icon Ġ= Ġevaluation Drawable ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Buy Action . text Ġ= Ġcontext . getString ( R . string . course _ purchase _ payment _ processing ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġevaluation Drawable . start () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġrender Terminal Button ( state : ĠCourse Purchase Feature . State . Content ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( state . payment State ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCourse Purchase Feature . Payment State . Payment Success Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġicon Ġ= ĠAppCompat Resources ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. get Drawable ( context , ĠR . drawable . ic _ purchase _ success _ check ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ? . mutate () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ? . let Ġ{ ĠDrawable Compat . wrap ( it ) Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ? . also Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠDrawable Compat . set Tint ( it , Ġcontext . resolve Color Attribute ( R . attr . color On Primary )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠDrawable Compat . set Tint Mode ( it , ĠPort er D uff . Mode . SRC _ IN ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Terminal Action . icon Ġ= Ġicon ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Terminal Action . text Ġ= Ġcontext . getString ( R . string . course _ purchase _ payment _ learn _ action ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Payment Title . text Ġ= Ġcontext . getString ( R . string . course _ purchase _ payment _ success ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Payment Icon . setImage Drawable ( AppCompat Resources . get Drawable ( context , ĠR . drawable . ic _ purchase _ success )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCourse Purchase Feature . Payment State . Payment Failure Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Terminal Action . icon Ġ= Ġnull ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Terminal Action . text Ġ= Ġcontext . getString ( R . string . course _ purchase _ payment _ restore _ action ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Payment Title . text Ġ= Ġcontext . getString ( R . string . course _ purchase _ payment _ failure ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Payment Icon . setImage Drawable ( AppCompat Resources . get Drawable ( context , ĠR . drawable . ic _ purchase _ fail )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠCourse Purchase Feature . Payment State . Payment Pending Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Terminal Action . icon Ġ= Ġnull ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Terminal Action . text Ġ= Ġcontext . getString ( R . string . course _ purchase _ payment _ ok _ action ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Payment Title . text Ġ= Ġcontext . getString ( R . string . course _ purchase _ payment _ pending ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Purchase Payment Icon . setImage Drawable ( AppCompat Resources . get Drawable ( context , ĠR . drawable . ic _ purchase _ pending )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġ{} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }