package Ġn ol ambda . link router . android . extra . caller . scenario Ċ Ċ import Ġandroid . content . Intent Ċ import Ġandroidx . activity . Component Activity Ċ import Ġandroidx . activity . result . Activity Result Ċ import Ġandroidx . activity . result . Activity Result Launcher Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġn ol ambda . link router . android . Route Ċ import Ġn ol ambda . link router . android . Route With Param Ċ import Ġn ol ambda . link router . android . extra . caller . create Launcher Ċ import Ġn ol ambda . link router . android . extra . caller . scenario . launcher . Parameterized Scenario Launcher Ċ import Ġn ol ambda . link router . android . extra . caller . scenario . launcher . Scenario Launcher Ċ import Ġn ol ambda . link router . android . extra . caller . scenario . processor . On Result Ċ import Ġn ol ambda . link router . android . extra . caller . scenario . processor . Ret ained Scenario Result Processor Ċ Ċ fun Ġ< P Ġ: ĠAny , ĠR > ĠComponent Activity . register Scenario For Result ( ĊĠĠĠ Ġscenario : ĠScenario < P , ĠR >, ĊĠĠĠ Ġon Callback : Ġ( R ) Ġ-> ĠUnit Ċ ): ĠParameter ized Scenario Launcher < P > Ġ{ ĊĠĠĠ Ġval Ġhost Ġ= ĠActivity Host ( this ) ĊĠĠĠ Ġval Ġinternal Launcher Ġ= Ġcreate Internal Launcher ( host , Ġscenario , Ġon Callback ) ĊĠĠĠ Ġreturn ĠParameter ized Scenario Launcher ( internal Launcher , Ġscenario . route Ġas ĠRoute With Param < P >) Ċ } Ċ Ċ fun Ġ< R > ĠComponent Activity . register Scenario For Result ( ĊĠĠĠ Ġscenario : ĠScenario < Unit , ĠR >, ĊĠĠĠ Ġon Callback : Ġ( R ) Ġ-> ĠUnit Ċ ): ĠScenario Launcher Ġ{ ĊĠĠĠ Ġval Ġhost Ġ= ĠActivity Host ( this ) ĊĠĠĠ Ġval Ġinternal Launcher Ġ= Ġcreate Internal Launcher ( host , Ġscenario , Ġon Callback ) ĊĠĠĠ Ġreturn ĠScenario Launcher ( internal Launcher , Ġscenario . route Ġas ĠRoute ) Ċ } Ċ Ċ fun Ġ< P Ġ: ĠAny , ĠR > ĠFragment . register Scenario For Result ( ĊĠĠĠ Ġscenario : ĠScenario < P , ĠR >, ĊĠĠĠ Ġon Callback : Ġ( R ) Ġ-> ĠUnit Ċ ): ĠParameter ized Scenario Launcher < P > Ġ{ ĊĠĠĠ Ġval Ġhost Ġ= ĠFragment Host ( this ) ĊĠĠĠ Ġval Ġinternal Launcher Ġ= Ġcreate Internal Launcher ( host , Ġscenario , Ġon Callback ) ĊĠĠĠ Ġreturn ĠParameter ized Scenario Launcher ( internal Launcher , Ġscenario . route Ġas ĠRoute With Param < P >) Ċ } Ċ Ċ fun Ġ< R > ĠFragment . register Scenario For Result ( ĊĠĠĠ Ġscenario : ĠScenario < Unit , ĠR >, ĊĠĠĠ Ġon Callback : Ġ( R ) Ġ-> ĠUnit Ċ ): ĠScenario Launcher Ġ{ ĊĠĠĠ Ġval Ġhost Ġ= ĠFragment Host ( this ) ĊĠĠĠ Ġval Ġinternal Launcher Ġ= Ġcreate Internal Launcher ( host , Ġscenario , Ġon Callback ) ĊĠĠĠ Ġreturn ĠScenario Launcher ( internal Launcher , Ġscenario . route Ġas ĠRoute ) Ċ } Ċ Ċ private Ġfun Ġ< R > Ġcreate Internal Launcher ( ĊĠĠĠ Ġhost : ĠScenario Host , ĊĠĠĠ Ġscenario : ĠScenario < *, ĠR >, ĊĠĠĠ Ġon Callback : Ġ( R ) Ġ-> ĠUnit Ċ ): ĠActivity Result Launcher < Intent > Ġ{ ĊĠĠĠ Ġval Ġprocessor Ġ= Ġscenario . processor ĊĊĠĠĠ Ġval Ġcontinuation Ġ= Ġ{ Ġactivity Result : ĠActivity Result Ġ-> ĊĠĠĠĠĠĠĠ Ġprocessor . process ( activity Result , Ġnull , Ġobject Ġ: ĠOn Result < R > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġcontinue With ( result : ĠR ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġon Callback ( result ) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( processor Ġis ĠRet ained Scenario Result Processor < R >) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprocessor . on Clear () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} ĊĠĠĠ Ġif Ġ( processor Ġis ĠRet ained Scenario Result Processor < R >) Ġ{ ĊĠĠĠĠĠĠĠ Ġprocessor . on Register ( host , Ġcontinuation ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġhost . create Launcher ( continu ation ) Ċ } Ċ Ċ private Ġfun ĠScenario Host . create Launcher ( callback : Ġ( Activity Result ) Ġ-> ĠUnit ) Ġ= Ġwhen Ġ( this ) Ġ{ ĊĠĠĠ Ġis ĠActivity Host Ġ-> Ġactivity . create Launcher ( callback ) ĊĠĠĠ Ġis ĠFragment Host Ġ-> Ġfragment . create Launcher ( callback ) Ċ } Ċ