package Ġcom . reg gar . tod om vp . feature . main Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . v 7 . widget . Linear LayoutManager Ċ import Ġandroid . support . v 7 . widget . RecyclerView Ċ import Ġandroid . view . Menu Ċ import Ġandroid . view . MenuItem Ċ import Ġandroid . view . input method . Editor Info Ċ import Ġandroid . widget . EditText Ċ import Ġandroid . widget . Image Button Ċ import Ġandroid . widget . Toolbar Ċ import Ġbutter knife . BindView Ċ import Ġbutter knife . B utter Kn ife Ċ import Ġcom . jak ew h art on . r xb ind ing 2 . view . click s Ċ import Ġcom . jak ew h art on . r xb ind ing 2 . widget . editor Actions Ċ import Ġcom . jak ew h art on . r xb ind ing 2 . widget . text Changes Ċ import Ġcom . reg gar . tod om vp . R Ċ import Ġcom . reg gar . tod om vp . data . Todo Ċ import Ġcom . reg gar . tod om vp . feature . main . adapter . Main Adapter Ċ import Ġdagger . android . Android Injection Ċ import Ġio . reactivex . Back pressure Strategy Ċ import Ġio . reactivex . Observable Ċ import Ġio . reactivex . subjects . Publish Subject Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠMainActivity Ġ: ĠActivity (), ĠMain Presenter . View Ġ{ ĊĠĠĠ Ġ@ BindView ( R . id . toolbar _ main ) Ġlateinit Ġvar Ġtoolbar : ĠToolbar ĊĠĠĠ Ġ@ BindView ( R . id . recyclerview _ main ) Ġlateinit Ġvar Ġre cyclerView : ĠRecyclerView ĊĠĠĠ Ġ@ BindView ( R . id . edit text _ ma ion ) Ġlateinit Ġvar Ġedit Text : ĠEditText ĊĠĠĠ Ġ@ BindView ( R . id . button _ main _ add ) Ġlateinit Ġvar Ġadd Button : ĠImage Button ĊĊĠĠĠ Ġ@ Inject Ġlateinit Ġvar Ġpresenter : ĠMain Presenter ĊĊĠĠĠ Ġprivate Ġval Ġon Todo Checked Ġ= ĠPublish Subject . create < Pair < Todo , ĠBoolean >>() ĊĠĠĠ Ġprivate Ġval Ġon Clear Completed Clicked Ġ= ĠPublish Subject . create < Unit >() ĊĊĠĠĠ Ġprivate Ġval Ġtodos Adapter Ġ= ĠMain Adapter Ġ{ ĊĠĠĠĠĠĠĠ Ġon Todo Checked . onNext ( it ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ ĠAndroid Injection . inject ( this ) ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( R . layout . activity _ main ) ĊĠĠĠĠĠĠĠ ĠB utter Kn ife . bind ( this ) ĊĠĠĠĠĠĠĠ Ġset ActionBar ( toolbar ) ĊĠĠĠĠĠĠĠ Ġpresenter . attach View ( this ) ĊĠĠĠĠĠĠĠ Ġre cyclerView . apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter Ġ= Ġtodos Adapter ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlayout Manager Ġ= ĠLinearLayoutManager ( this @ MainActivity ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate Options Menu ( menu : ĠMenu ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġmenu Inflater . inflate ( R . menu . menu _ main , Ġmenu ) ĊĠĠĠĠĠĠĠ Ġreturn Ġtrue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Options ItemSelected ( item : ĠMenuItem ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġwhen Ġ( item . itemId ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠR . id . action _ clear Ġ-> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġon Clear Completed Clicked . onNext ( Unit ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn Ġtrue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Destroy () Ġ{ ĊĠĠĠĠĠĠĠ Ġpresenter . detach View () ĊĠĠĠĠĠĠĠ Ġsuper . on Destroy () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon TextChanged (): ĠObservable < CharSequence > Ġ= Ġedit Text . text Changes (). to Flow able ( Back pressure Strategy . LATE ST ). to Observable () ĊĊĠĠĠ Ġoverride Ġfun Ġon Todo Checked Change (): ĠObservable < Pair < Todo , ĠBoolean >> Ġ= Ġon Todo Checked . to Flow able ( Back pressure Strategy . LATE ST ). to Observable () ĊĊĠĠĠ Ġoverride Ġfun Ġon Add Clicked (): ĠObservable < Unit > Ġ= Ġadd Button . click s (). merge With ( edit Text . editor Actions (). filter Ġ{ Ġit Ġ== ĠEditor Info . IME _ ACTION _ DONE Ġ}. map Ġ{ ĠUnit Ġ}) ĊĊĠĠĠ Ġoverride Ġfun Ġon Remove Completed Clicked (): ĠObservable < Unit > Ġ= Ġon Clear Completed Clicked . to Flow able ( Back pressure Strategy . LATE ST ). to Observable () ĊĊĠĠĠ Ġoverride Ġfun Ġshow Todos ( in complete Todos : ĠList < Todo >, Ġcomplete Todos : ĠList < Todo >) Ġ{ ĊĠĠĠĠĠĠĠ Ġtodos Adapter . set Items ( in complete Todos , Ġcomplete Todos ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġclear Text () Ġ{ ĊĠĠĠĠĠĠĠ Ġedit Text . setText ("") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġtoggle Submit ( isEnabled : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġadd Button . isEnabled Ġ= Ġis Enabled ĊĠĠĠ Ġ} Ċ } Ċ