package Ġcom . example . sat ri ak urn i awan . data . repository Ċ Ċ import Ġcom . example . sat ri ak urn i awan . data . entities . My Character Ċ import Ġcom . example . sat ri ak urn i awan . data . local . Character Dao Ċ import Ġcom . example . sat ri ak urn i awan . data . remote . Character Remote DataSource Ċ import Ġcom . example . sat ri ak urn i awan . utils . perform Get Local Only Ċ import Ġcom . example . sat ri ak urn i awan . utils . perform Get Operation Ċ import Ġcom . example . sat ri ak urn i awan . utils . perform Get Remote Only Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠCharacter Repository Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġremote DataSource : ĠCharacter Remote DataSource , ĊĠĠĠ Ġprivate Ġval Ġlocal DataSource : ĠCharacter Dao Ċ ) Ġ{ ĊĊĠĠĠ Ġfun Ġget Character ( id : ĠString ) Ġ= Ġperform Get Remote Only ( ĊĠĠĠĠĠĠĠ Ġnetwork Call Ġ= Ġ{ Ġremote DataSource . get Character ( id ) Ġ} ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġfun Ġget Characters () Ġ= Ġperform Get Operation ( ĊĠĠĠĠĠĠĠ Ġdatabase Query Ġ= Ġ{ Ġlocal DataSource . getAll Characters () Ġ}, ĊĠĠĠĠĠĠĠ Ġnetwork Call Ġ= Ġ{ Ġremote DataSource . get Characters () Ġ}, ĊĠĠĠĠĠĠĠ Ġsave Call Result Ġ= Ġ{ Ġlocal DataSource . insert All ( it . results ) Ġ} ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġfun Ġget My Characters () Ġ= Ġperform Get Local Only Ġ{ Ġlocal DataSource . getC atched Pokemon () Ġ} ĊĊĠĠĠ Ġfun Ġinsert My Pokemon ( character Ġ: ĠMy Character ) Ġ= Ġlocal DataSource . insert My Pokemon ( character ) ĊĠĠĠ Ġfun Ġupdate My Pokemon ( character Ġ: ĠMy Character ) Ġ= Ġlocal DataSource . update My Pokemon ( character ) Ċ Ċ }