package Ġcom . cent aur y . catalog ue movie . favorite . view model Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġcom . cent aur y . catalog ue movie . utils . Loader State Ċ import Ġcom . cent aur y . catalog ue movie . utils . Status Ċ import Ġcom . cent aur y . domain . Flow able UseCase Ċ import Ġcom . cent aur y . domain . model . TV Shows DB Ċ import Ġcom . cent aur y . domain . tv show . inter actor . GetAll Favorite TV Show Ċ import Ġcom . cent aur y . domain . tv show . inter actor . Get Delete Favorite TV Show Ċ import Ġcom . cent aur y . domain . tv show . inter actor . Get Favorite TV Show ById Ċ import Ġjavax . inject . Inject Ċ Ċ /** Ċ Ġ* ĠCreated Ġby ĠCent aur y Ġon Ġ 1 1 / 2 3 / 2 0 1 9 . Ċ Ġ*/ Ċ class ĠF avorite TV Show ViewModel Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval ĠgetAll Favorite TV Show : ĠGetAll Favorite TV Show , ĊĠĠĠ Ġprivate Ġval Ġget Favorite TV Show ById : ĠGet Favorite TV Show ById , ĊĠĠĠ Ġprivate Ġval Ġget Delete Favorite TV Show : ĠGet Delete Favorite TV Show Ċ ) Ġ: ĠViewModel (), ĠF avorite TV Show Contract Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġ_ state Ġ= ĠMutable LiveData < Loader State >() ĊĠĠĠ Ġval Ġstate : ĠLive Data < Loader State > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ state ĊĊĠĠĠ Ġprivate Ġval Ġ_ result Ġ= ĠMutable LiveData < List < TV Shows DB >>() ĊĠĠĠ Ġval Ġresult : ĠLive Data < List < TV Shows DB >> ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ result ĊĊĠĠĠ Ġprivate Ġval Ġ_ error Ġ= ĠMutable LiveData < String >() ĊĠĠĠ Ġval Ġerror : ĠLive Data < String > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ error ĊĊĠĠĠ Ġprivate Ġval Ġ_ result TV Show ById Ġ= ĠMutable LiveData < TV Shows DB >() ĊĠĠĠ Ġval Ġresult TV Show ById : ĠLive Data < TV Shows DB > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ result TV Show ById ĊĊĠĠĠ Ġprivate Ġval Ġ_ error TV Show ById Ġ= ĠMutable LiveData < String >() ĊĠĠĠ Ġval Ġerror TV Show ById : ĠLive Data < String > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ error TV Show ById ĊĊĠĠĠ Ġprivate Ġval Ġ_ result Delete TV Show Ġ= ĠMutable LiveData < Status >() ĊĠĠĠ Ġval Ġresult Delete TV Show : ĠLive Data < Status > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ result Delete TV Show ĊĊĠĠĠ Ġprivate Ġval Ġ_ error Delete TV Show Ġ= ĠMutable LiveData < String >() ĊĠĠĠ Ġval Ġerror Delete TV Show : ĠLive Data < String > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ error Delete TV Show ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ ĠgetAll Favorite TV Show Contract () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠgetAll Favorite TV Show Contract () Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ state . value Ġ= ĠLoader State . Show Loading ĊĠĠĠĠĠĠĠ ĠgetAll Favorite TV Show . execute ( Flow able UseCase . None (), ĠonSuccess Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ state . value Ġ= ĠLoader State . Hide Loading ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ result . post Value ( it ) ĊĠĠĠĠĠĠĠ Ġ}, ĠonError Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ state . value Ġ= ĠLoader State . Hide Loading ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ error . post Value ( it . message ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Favorite TV Show ById Contract ( tv Show Id : ĠInt ) Ġ= ĊĠĠĠĠĠĠĠ Ġget Favorite TV Show ById . execute ( Get Favorite TV Show ById . Params ( tv Show Id ), ĠonSuccess Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ result TV Show ById . post Value ( it ) ĊĠĠĠĠĠĠĠ Ġ}, ĠonError Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ error TV Show ById . post Value ( it . message ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠ Ġoverride Ġfun Ġget Delete Favorite TV Show Contract ( tv Show : ĠTV Shows DB ) Ġ= ĊĠĠĠĠĠĠĠ Ġget Delete Favorite TV Show . execute ( tv Show , ĠonSuccess Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ result Delete TV Show . value Ġ= ĠStatus . SUCCESS ĊĠĠĠĠĠĠĠ Ġ}, ĠonError Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ error Delete TV Show . post Value ( it . message ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĠĠĠ Ġoverride Ġfun Ġon Cle ared () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Cle ared () ĊĠĠĠĠĠĠĠ Ġget Favorite TV Show ById . dispose () ĊĠĠĠĠĠĠĠ ĠgetAll Favorite TV Show . dispose () ĊĠĠĠĠĠĠĠ Ġget Delete Favorite TV Show . dispose () ĊĠĠĠ Ġ} Ċ } Ċ