package Ġcom . pix is . tr akt TV . base Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġn ucleus 5 . factory . Presenter Factory Ċ import Ġn ucleus 5 . factory . Reflection Presenter Factory Ċ import Ġn ucleus 5 . presenter . Presenter Ċ import Ġn ucleus 5 . view . Presenter Lifecycle Delegate Ċ import Ġn ucleus 5 . view . View With Presenter Ċ /* Ċ /** Ċ Ġ* ĠFrom ĠN ucleus AppCompatActivity Ċ Ġ*/ Ċ abstract Ġclass ĠBase Rx Activity < P Ġ: ĠPres enter <* >> Ġ: ĠBase Activity (), ĠView With Presenter < P > Ġ{ ĊĊĠĠĠ Ġprivate Ġval ĠP RES ENTER _ STATE _ KEY Ġ= Ġ" presenter _ state " ĊĊĠĠĠ Ġprivate Ġval Ġpresenter Delegate : ĠPres enter Lifecycle Delegate < P > Ġ= ĠPres enter Lifecycle Delegate ( null ) ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠReturns Ġa Ġcurrent Ġpresenter Ġfactory . ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġoverride Ġfun Ġget Presenter Factory (): ĠPres enter Factory < P > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġpresenter Delegate . presenter Factory !! ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠSets Ġa Ġpresenter Ġfactory . ĊĠĠĠĠ Ġ* ĠCall Ġthis Ġmethod Ġbefore ĠonCreate / on Finish Inf late Ġto Ġoverride Ġdefault Ġ[ Reflection Presenter Factory ] Ġpresenter Ġfactory . ĊĠĠĠĠ Ġ* ĠUse Ġthis Ġmethod Ġfor Ġpresenter Ġdependency Ġinjection . ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġoverride Ġfun Ġset Presenter Factory ( presenter Factory : ĠPres enter Factory < P >) Ġ{ ĊĠĠĠĠĠĠĠ Ġpresenter Delegate . presenter Factory Ġ= Ġpresenter Factory ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĊĠĠĠĠ Ġ* ĠReturns Ġa Ġcurrent Ġattached Ġpresenter . ĊĠĠĠĠ Ġ* ĠThis Ġmethod Ġis Ġguaranteed Ġto Ġreturn Ġa Ġnon - null Ġvalue Ġbetween ĊĠĠĠĠ Ġ* Ġon Resume / on Pause Ġand Ġon Attached To Window / on Detached From Window Ġcalls ĊĠĠĠĠ Ġ* Ġif Ġthe Ġpresenter Ġfactory Ġreturns Ġa Ġnon - null Ġvalue . ĊĊĠĠĠĠ Ġ* Ġ@ return Ġa Ġcurrently Ġattached Ġpresenter Ġor Ġnull . ĊĠĠĠĠ Ġ*/ ĊĠĠĠ Ġoverride Ġfun Ġget Presenter (): ĠP Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġpresenter Delegate . presenter ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsuper Factory Ġ= ĠReflection Presenter Factory . from View Class < P >( java Class ) Ġ?: Ġthrow ĠRuntimeException (" Did Ġnot Ġcall Ġ@ Requires Presenter ") ĊĠĠĠĠĠĠĠ Ġpresenter Factory Ġ= ĠPres enter Factory < P > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġpresenter Ġ= Ġsuper Factory . create Presenter () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġinject Presenter ( presenter ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpresenter ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġif Ġ( savedInstanceState Ġ!= Ġnull ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpresenter Delegate . on Restore InstanceState ( savedInstanceState . get Bundle ( PRES ENTER _ STATE _ KEY )) ĊĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġopen Ġfun Ġinject Presenter ( presenter : ĠP ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ// Override Ġto Ġactually Ġinject ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Save InstanceState ( out State : ĠBundle ) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Save InstanceState ( out State ) ĊĠĠĠĠĠĠĠ Ġout State . put Bundle ( PRES ENTER _ STATE _ KEY , Ġpresenter Delegate . on Save InstanceState ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Resume () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Resume () ĊĠĠĠĠĠĠĠ Ġpresenter Delegate . on Resume ( this ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Pause () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Pause () ĊĠĠĠĠĠĠĠ Ġpresenter Delegate . on Drop View () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Destroy () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Destroy () ĊĠĠĠĠĠĠĠ Ġpresenter Delegate . on Destroy (! is Changing Configurations ) ĊĠĠĠ Ġ} Ċ }*/