package Ġcom . tom cl aw . draw a . draw Ċ Ċ import Ġandroid . view . View Ċ import Ġandroid . widget . View Flip per Ċ import Ġandroidx . appcompat . widget . Toolbar Ċ import Ġcom . jak ew h art on . rx relay 2 . Publish Relay Ċ import Ġcom . tom cl aw . draw a . R Ċ import Ġcom . tom cl aw . draw a . draw . tools . Tool Ċ import Ġcom . tom cl aw . draw a . draw . view . Drawing Listener Ċ import Ġcom . tom cl aw . draw a . draw . view . Drawing View Ċ import Ġcom . tom cl aw . draw a . draw . view . Touch Event Ċ import Ġcom . tom cl aw . draw a . util . Metrics Provider Ċ import Ġcom . tom cl aw . draw a . util . hide With Alpha Animation Ċ import Ġcom . tom cl aw . draw a . util . show With Alpha Animation Ċ import Ġio . reactivex . Observable Ċ Ċ interface ĠDraw View Ġ: ĠTools View Ġ{ ĊĊĠĠĠ Ġfun Ġset Drawing Listener ( listener : ĠDraw ing Listener ) ĊĊĠĠĠ Ġfun Ġaccept Tool ( tool : ĠTool ) ĊĊĠĠĠ Ġfun Ġshow Progress () ĊĊĠĠĠ Ġfun Ġshow Overlay Progress () ĊĊĠĠĠ Ġfun Ġshow Content () ĊĊĠĠĠ Ġfun Ġtouch Events (): ĠObservable < Touch Event > ĊĊĠĠĠ Ġfun Ġdraw Events (): ĠObservable < Unit > ĊĊĠĠĠ Ġfun Ġnavigation Click s (): ĠObservable < Unit > ĊĊĠĠĠ Ġfun Ġundo Click s (): ĠObservable < Unit > ĊĊĠĠĠ Ġfun Ġplay Click s (): ĠObservable < Unit > ĊĊĠĠĠ Ġfun Ġshare Click s (): ĠObservable < Unit > ĊĊĠĠĠ Ġfun Ġduplicate Click s (): ĠObservable < Unit > ĊĊĠĠĠ Ġfun Ġdelete Click s (): ĠObservable < Unit > Ċ Ċ } Ċ Ċ class ĠDraw View Impl ( ĊĠĠĠĠĠĠĠ Ġview : ĠView , ĊĠĠĠĠĠĠĠ Ġdraw Host Holder : ĠDraw Host Holder , ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġmetrics Provider : ĠMetrics Provider Ċ ) Ġ: ĠDraw View , ĠTools View Ġby ĠTools View Impl ( view ) Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġtoolbar : ĠToolbar Ġ= Ġview . findViewById ( R . id . toolbar ) ĊĠĠĠ Ġprivate Ġval Ġdrawing View : ĠDraw ing View Ġ= Ġview . findViewById ( R . id . drawing _ view ) ĊĠĠĠ Ġprivate Ġval Ġoverlay Progress : ĠView Ġ= Ġview . findViewById ( R . id . overlay _ progress ) ĊĠĠĠ Ġprivate Ġval Ġflip per : ĠView Flip per Ġ= Ġview . findViewById ( R . id . flip per ) ĊĠĠĠ Ġprivate Ġval Ġundo Button : ĠView Ġ= Ġview . findViewById ( R . id . undo _ button ) ĊĊĠĠĠ Ġprivate Ġval Ġtouch Relay Ġ= ĠPublish Relay . create < Touch Event >() ĊĠĠĠ Ġprivate Ġval Ġdraw Relay Ġ= ĠPublish Relay . create < Unit >() ĊĠĠĠ Ġprivate Ġval Ġnavigation Relay Ġ= ĠPublish Relay . create < Unit >() ĊĠĠĠ Ġprivate Ġval Ġundo Relay Ġ= ĠPublish Relay . create < Unit >() ĊĠĠĠ Ġprivate Ġval Ġplay Relay Ġ= ĠPublish Relay . create < Unit >() ĊĠĠĠ Ġprivate Ġval Ġshare Relay Ġ= ĠPublish Relay . create < Unit >() ĊĠĠĠ Ġprivate Ġval Ġduplicate Relay Ġ= ĠPublish Relay . create < Unit >() ĊĠĠĠ Ġprivate Ġval Ġdelete Relay Ġ= ĠPublish Relay . create < Unit >() ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġdraw Host Holder . draw Host Ġ= Ġdrawing View ĊĠĠĠĠĠĠĠ Ġtoolbar . setTitle ( R . string . draw ) ĊĠĠĠĠĠĠĠ Ġtoolbar . set Navigation OnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnavigation Relay . accept ( Unit ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġtoolbar . inflate Menu ( R . menu . draw ) ĊĠĠĠĠĠĠĠ Ġtoolbar . setOn MenuItem ClickListener Ġ{ Ġitem Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhen Ġ( item . itemId ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . menu _ share Ġ-> Ġshare Relay . accept ( Unit ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . menu _ play Ġ-> Ġplay Relay . accept ( Unit ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . menu _ duplicate Ġ-> Ġduplicate Relay . accept ( Unit ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . menu _ delete Ġ-> Ġdelete Relay . accept ( Unit ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtrue ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġundo Button . setOnClickListener Ġ{ Ġundo Relay . accept ( Unit ) Ġ} ĊĠĠĠĠĠĠĠ Ġdrawing View . drawing Listener Ġ= Ġobject Ġ: ĠDraw ing Listener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Touch Event ( event : ĠTouch Event ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġtouch Relay . accept ( event ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Draw () Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġdraw Relay . accept ( Unit ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġset Drawing Listener ( listener : ĠDraw ing Listener ) Ġ{ ĊĠĠĠĠĠĠĠ Ġdrawing View . drawing Listener Ġ= Ġlistener ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġaccept Tool ( tool : ĠTool ) Ġ{ ĊĠĠĠĠĠĠĠ Ġtool . initialize ( drawing View , Ġmetrics Provider ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Progress () Ġ{ ĊĠĠĠĠĠĠĠ Ġflip per . display ed Child Ġ= Ġ 0 ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Overlay Progress () Ġ{ ĊĠĠĠĠĠĠĠ Ġoverlay Progress . show With Alpha Animation ( animate Fully Ġ= Ġtrue ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Content () Ġ{ ĊĠĠĠĠĠĠĠ Ġflip per . display ed Child Ġ= Ġ 1 ĊĠĠĠĠĠĠĠ Ġoverlay Progress . hide With Alpha Animation ( animate Fully Ġ= Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġtouch Events (): ĠObservable < Touch Event > Ġ= Ġtouch Relay ĊĊĠĠĠ Ġoverride Ġfun Ġdraw Events (): ĠObservable < Unit > Ġ= Ġdraw Relay ĊĊĠĠĠ Ġoverride Ġfun Ġnavigation Click s (): ĠObservable < Unit > Ġ= Ġnavigation Relay ĊĊĠĠĠ Ġoverride Ġfun Ġundo Click s (): ĠObservable < Unit > Ġ= Ġundo Relay ĊĊĠĠĠ Ġoverride Ġfun Ġplay Click s (): ĠObservable < Unit > Ġ= Ġplay Relay ĊĊĠĠĠ Ġoverride Ġfun Ġshare Click s (): ĠObservable < Unit > Ġ= Ġshare Relay ĊĊĠĠĠ Ġoverride Ġfun Ġduplicate Click s (): ĠObservable < Unit > Ġ= Ġduplicate Relay ĊĊĠĠĠ Ġoverride Ġfun Ġdelete Click s (): ĠObservable < Unit > Ġ= Ġdelete Relay Ċ Ċ } Ċ