package Ġcom . nick tra . movies quare . data . source . local Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . paging . DataSource Ċ import Ġcom . nick tra . movies quare . data . source . local . entity . Movie Entity Ċ import Ġcom . nick tra . movies quare . data . source . local . entity . Show Entity Ċ import Ġcom . nick tra . movies quare . data . source . local . room . Catalog ue Dao Ċ Ċ class ĠLocal DataSource Ġprivate Ġconstructor ( private Ġval Ġm Catalog ue Dao : ĠCatalog ue Dao ) Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġvar ĠINSTANCE : ĠLocal DataSource ? Ġ= Ġnull ĊĊĠĠĠĠĠĠĠ Ġfun ĠgetInstance ( catalog ue Dao : ĠCatalog ue Dao ): ĠLocal DataSource Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠINSTANCE Ġ?: ĠLocal DataSource ( catalog ue Dao ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠMovie ĊĠĠĠ Ġfun ĠgetAll Movies (): ĠDataSource . Factory < Int , ĠMovie Entity > Ġ= Ġm Catalog ue Dao . get Movies () ĊĊĠĠĠ Ġfun Ġinsert Movies ( movies : ĠList < Movie Entity >) Ġ= Ġm Catalog ue Dao . insert Movies ( movies ) ĊĊĠĠĠ Ġfun Ġget Movie ById ( movie Id : ĠInt ): ĠLive Data < Movie Entity > Ġ= Ġm Catalog ue Dao . get Movie ById ( movie Id ) ĊĊĠĠĠ Ġfun Ġupdate Movie ById ( movie : ĠMovie Entity ) Ġ= Ġm Catalog ue Dao . update Movie ( movie ) ĊĊĠĠĠ Ġfun Ġget Favorite Movies (): ĠDataSource . Factory < Int , ĠMovie Entity > Ġ= Ġm Catalog ue Dao . get Favorite Movies () ĊĊĠĠĠ Ġfun Ġset Movie Favorite ( movie : ĠMovie Entity , ĠnewState : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmovie . is Favorite Ġ= ĠnewState ĊĠĠĠĠĠĠĠ Ġm Catalog ue Dao . update Movie ( movie ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠShow ĊĠĠĠ Ġfun ĠgetAll Shows (): ĠDataSource . Factory < Int , ĠShow Entity > Ġ= Ġm Catalog ue Dao . get Shows () ĊĊĠĠĠ Ġfun Ġinsert Shows ( shows : ĠList < Show Entity >) Ġ= Ġm Catalog ue Dao . insert Shows ( shows ) ĊĊĠĠĠ Ġfun Ġget Show ById ( show Id : ĠInt ): ĠLive Data < Show Entity > Ġ= Ġm Catalog ue Dao . get Show ById ( show Id ) ĊĊĠĠĠ Ġfun Ġupdate Show ById ( show : ĠShow Entity ) Ġ= Ġm Catalog ue Dao . update Show ( show ) ĊĊĠĠĠ Ġfun Ġget Favorite Shows (): ĠDataSource . Factory < Int , ĠShow Entity > Ġ= Ġm Catalog ue Dao . get Favorite Shows () ĊĊĠĠĠ Ġfun ĠsetShow Favorite ( show : ĠShow Entity , ĠnewState : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġshow . is Favorite Ġ= ĠnewState ĊĠĠĠĠĠĠĠ Ġm Catalog ue Dao . update Show ( show ) ĊĠĠĠ Ġ} Ċ Ċ }