package Ġcom . github . android p ir ate . caps ul ere views . data . db Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . room .* Ċ import Ġcom . github . android p ir ate . caps ul ere views . data . db . entity . DB Favorite Ċ import Ġcom . github . android p ir ate . caps ul ere views . util . internal . Constants Ċ Ċ @ Dao Ċ interface ĠF avorites Dao Ġ{ ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġfavor ites ") ĊĠĠĠ Ġfun Ġget F avorites (): ĠLive Data < List < DB Favorite >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġfavor ites ĠWHERE Ġtype Ġ= Ġ: type Movie ĠORDER ĠBY Ġb inge Status ") ĊĠĠĠ Ġfun Ġget Favorite Movies ( type Movie : ĠString Ġ= ĠConstants . FA V OR ITE _ MOV IE _ TYPE ): ĠLive Data < List < DB Favorite >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġfavor ites ĠWHERE Ġtype Ġ= Ġ: type Tv Show ĠORDER ĠBY Ġb inge Status ") ĊĠĠĠ Ġfun Ġget Favorite Tv Shows ( type Tv Show : ĠString Ġ= ĠConstants . FA V OR ITE _ TV _ SHOW _ TYPE ): ĠLive Data < List < DB Favorite >> ĊĊĠĠĠ Ġ@ Query (" SELECT Ġ* ĠFROM Ġfavor ites ĠWHERE Ġid Ġ= Ġ: id ") ĊĠĠĠ Ġfun Ġget Favorite ById ( id : ĠInt ): ĠLive Data < DB Favorite > ĊĊĠĠĠ Ġ@ Query (" SELECT ĠEXISTS ( SELECT Ġ* ĠFROM Ġfavor ites ĠWHERE Ġid Ġ= Ġ: id )") ĊĠĠĠ Ġfun Ġis Row Is Exist ( id Ġ: ĠInt ) Ġ: ĠBoolean ĊĊĠĠĠ Ġ@ Query (" DELETE ĠFROM Ġfavor ites ĠWHERE Ġid Ġ= Ġ: id ") ĊĠĠĠ Ġsuspend Ġfun Ġdelete Favorite With Id ( id : ĠInt ) ĊĊĠĠĠ Ġ@ Query (" UPDATE Ġfavor ites ĠSET Ġb inge Status Ġ= Ġ: status ĠWHERE Ġid Ġ= Ġ: id ") ĊĠĠĠ Ġsuspend Ġfun Ġupdate Favorite Status ( status : ĠString , Ġid : ĠInt ) ĊĊĠĠĠ Ġ@ Insert ( on Conflict Ġ= ĠOn Conflict Strategy . REPLACE ) ĊĠĠĠ Ġsuspend Ġfun Ġinsert Favorite ( favorite : ĠDB Favorite ) ĊĊĠĠĠ Ġ@ Delete ĊĠĠĠ Ġsuspend Ġfun Ġdelete Favorite ( favorite : ĠDB Favorite ) Ċ Ċ }