package Ġcom . film ly . app . ui . episode Ċ Ċ import Ġandroid . util . Log Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġcom . film ly . app . data . model . Watch able Ċ import Ġcom . film ly . app . repository . Services Repository Ċ import Ġcom . film ly . app . ui . card Detail . Tv Episode s Result Ċ import Ġkotlinx . coroutines . launch Ċ Ċ class ĠSe ason Detail ViewModel ( val Ġrepository : ĠServices Repository ): ĠViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġ_ tv Episode s Live Ġ= ĠMutable LiveData < Tv Episode s Result >() ĊĠĠĠ Ġval Ġtv Episode s Live : ĠLive Data < Tv Episode s Result > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ tv Episode s Live ĊĊĠĠĠ Ġfun Ġget Episode Tv Detail ( id : ĠInt , Ġseason _ number : ĠInt ){ ĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ_ tv Episode s Live . value Ġ= Ġrepository . get Episode s Model ( id , Ġseason _ number ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} catch Ġ( e : ĠException ){ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠLog . e (" Card Detail ViewModel ", Ġe . toString ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Episode W atched ( watch able : ĠWatch able ){ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . insert W atched ( watch able ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊ Ċ }