package Ġ` in `. ob vious . android . starter . counter Ċ Ċ import Ġcom . spotify . mob ius . Connect able Ċ import Ġcom . spotify . mob ius . Connection Ċ import Ġcom . spotify . mob ius . functions . Consumer Ċ import Ġ` in `. ob vious . android . starter . mob ius . Ui Work Runner Ċ import Ġ` in `. ob vious . android . starter . util . Cancel able Ċ Ċ class ĠCounter Effect Handler ( ĊĠ Ġprivate Ġval Ġcount down Factory : ĠCount down . Factory , ĊĠ Ġprivate Ġval Ġui Work Runner : ĠUi Work Runner Ċ ) Ġ: ĠConnect able < Counter Effect , ĠCounter Event > Ġ{ ĊĊĠ Ġprivate Ġvar Ġcancell ables : ĠList < Cancel able > Ġ= Ġempty List () ĊĊĠ Ġoverride Ġfun Ġconnect ( events : ĠConsumer < Counter Event >): ĠConnection < Counter Effect > Ġ{ ĊĠĠĠ Ġreturn Ġobject Ġ: ĠConnection < Counter Effect > Ġ{ ĊĊĠĠĠĠĠ Ġoverride Ġfun Ġaccept ( effect : ĠCounter Effect ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( effect ) Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġis ĠStart Count down Ġ-> Ġstart Count down ( effect , Ġevents ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġoverride Ġfun Ġdispose () Ġ{ ĊĠĠĠĠĠĠĠ Ġcancell ables . forEach ( Cancel able :: cancel ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġstart Count down ( effect : ĠStart Count down , Ġevents : ĠConsumer < Counter Event >) Ġ{ ĊĠĠĠ Ġui Work Runner . post Ġ{ ĊĠĠĠĠĠ Ġval Ġcount down Ġ= Ġcount down Factory . create () ĊĊĠĠĠĠĠ Ġcount down . start ( ĊĠĠĠĠĠĠĠ Ġtick Amount Ġ= Ġeffect . ticks , ĊĠĠĠĠĠĠĠ Ġtick TimeUnit Ġ= Ġeffect . time Unit , ĊĠĠĠĠĠĠĠ Ġtick Ġ= Ġ{ Ġevents . accept ( Count down Tick ) Ġ}, ĊĠĠĠĠĠĠĠ Ġdone Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠ Ġevents . accept ( Count down Complete ) ĊĠĠĠĠĠĠĠĠĠ Ġremove Cancel able ( countdown ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠ Ġadd C ancellable ( countdown ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġadd C ancellable ( cancel able : ĠCancel able ) Ġ{ ĊĠĠĠ Ġcancell ables Ġ= Ġcancell ables Ġ+ Ġcancel able ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġremove Cancel able ( cancel able : ĠCancel able ) Ġ{ ĊĠĠĠ Ġcancell ables Ġ= Ġcancell ables Ġ- Ġcancel able ĊĠ Ġ} Ċ } Ċ