package Ġcom . mand iri . movie . model . room . repositories Ċ Ċ import Ġandroid . app . Application Ċ import Ġcom . mand iri . movie . model . data . Watch list Movie Ċ import Ġcom . mand iri . movie . model . room . databases . Watch list Database Ċ import Ġkotlinx . coroutines . Coroutine Scope Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . launch Ċ import Ġkotlinx . coroutines . with Context Ċ import Ġkotlin . coroutines . Coroutine Context Ċ Ċ class ĠWatch list Repository ( application : ĠApplication ) Ġ: ĠCor outine Scope Ġ{ ĊĠĠĠ Ġoverride Ġval Ġcoroutine Context : ĠCor outine Context ĊĠĠĠĠĠĠĠ Ġget () Ġ= ĠDispatch ers . Main ĊĊĠĠĠ Ġprivate Ġval Ġwatch list Movie Dao Ġ= ĠWatch list Database . getInstance ( application ). watch list Movie Dao () ĊĊĠĠĠ Ġfun Ġinsert OrUpdate Movie ( watch list Movie : ĠWatch list Movie ) Ġ{ ĊĠĠĠĠĠĠĠ Ġlaunch Ġ{ Ġinsert OrUpdate Movie BG ( watch list Movie ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġsuspend Ġfun Ġinsert OrUpdate Movie BG ( watch list Movie : ĠWatch list Movie ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwith Context ( Dispatch ers . IO ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwatch list Movie Dao . insert OrUpdate Movie ( watch list Movie ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun ĠgetAll Movies () Ġ= Ġwatch list Movie Dao . getAll Movies () ĊĊĠĠĠ Ġsuspend Ġfun ĠgetAll Movie Ids () Ġ= Ġwatch list Movie Dao . getAll Movie Ids () ĊĊĠĠĠ Ġfun Ġdelete Watch list Movie ( movie Id : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġlaunch Ġ{ Ġdelete Watch list Movie BG ( movie Id ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġsuspend Ġfun Ġdelete Watch list Movie BG ( movie Id : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġwith Context ( Dispatch ers . IO ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwatch list Movie Dao . delete Movie ById ( movie Id ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }