package Ġorg . k oin . sample . android x . scope Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġkotlinx . android . synt hetic . main . scoped _ activity _ a .* Ċ import Ġorg . junit . Assert .* Ċ import Ġorg . k oin . android x . scope . Scope Activity Ċ import Ġorg . k oin . core . qual ifier . named Ċ import Ġorg . k oin . sample . android . R Ċ import Ġorg . k oin . sample . android x . components .* Ċ import Ġorg . k oin . sample . android x . components . scope . Session Ċ import Ġorg . k oin . sample . android x . components . scope . Session Activity Ċ import Ġorg . k oin . sample . android x . utils . navigate To Ċ Ċ class ĠScoped Activity A Ġ: ĠScope Activity ( content Layout Id Ġ= ĠR . layout . scoped _ activity _ a ) Ġ{ ĊĊĠĠĠ Ġ// ĠInject Ġfrom Ġcurrent Ġscope ĊĠĠĠ Ġval Ġcurrent Session Ġby Ġinject < Session >() ĊĠĠĠ Ġval Ġcurrent Activity Session Ġby Ġinject < Session Activity >() ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĊĠĠĠĠĠĠĠ ĠassertEquals ( current Session , Ġget < Session >()) ĊĊĠĠĠĠĠĠĠ Ġ// ĠCon pare Ġdifferent Ġscope Ġinstances ĊĠĠĠĠĠĠĠ Ġval Ġscope Session 1 Ġ= Ġget K oin (). create Scope ( SESSION _ 1 , Ġnamed ( SCOPE _ ID )) ĊĠĠĠĠĠĠĠ Ġval Ġscope Session 2 Ġ= Ġget K oin (). create Scope ( SESSION _ 2 , Ġnamed ( SCOPE _ ID )) ĊĠĠĠĠĠĠĠ Ġassert Not Equals ( scope Session 1 . get < Session >( named ( SCOPE _ SESSION )), Ġcurrent Session ) ĊĠĠĠĠĠĠĠ Ġassert Not Equals ( scope Session 1 . get < Session >( named ( SCOPE _ SESSION )), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġscope Session 2 . get < Session >( named ( SCOPE _ SESSION ))) ĊĊĊĠĠĠĠĠĠĠ Ġ// Ġset Ġdata Ġin Ġscope ĠSCO PE _ ID ĊĠĠĠĠĠĠĠ Ġval Ġsession Ġ= Ġget K oin (). create Scope ( SCOPE _ ID , Ġnamed ( SCOPE _ ID )). get < Session >( named ( SCOPE _ SESSION )) ĊĠĠĠĠĠĠĠ Ġsession . id Ġ= ĠID ĊĊĠĠĠĠĠĠĠ Ġtitle Ġ= Ġ" Scope ĠActivity ĠA " ĊĊĠĠĠĠĠĠĠ Ġscoped _ a _ button . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnavigate To < Scoped Activity B >( is Root Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠassertTrue ( this Ġ== Ġcurrent Activity Session . activity ) ĊĠĠĠ Ġ} Ċ }