package Ġcom . die go be z erra . cin em ais app . ui . main . cin em as Ċ Ċ import Ġandroidx . h ilt . lifecycle . ViewModel Inject Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mediator LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġcom . die go be z erra . cin em ais app . base . Base ViewModel Ċ import Ġcom . die go be z erra . cin em ais app . data . local . Preferences Helper Ċ import Ġcom . die go be z erra . core . cin em ais . data . cin em as . C in ema Repository Ċ import Ġcom . die go be z erra . core . cin em ais . domain . model . C in ema Ċ import Ġcom . die go be z erra . shared . result . Event Ċ Ċ class ĠC in em as ViewModel Ġ@ ViewModel Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġcin ema Repository : ĠC in ema Repository , ĊĠĠĠ Ġprivate Ġval Ġpreferences Helper : ĠPreferences Helper Ċ ) Ġ: ĠBase ViewModel (), ĠC in em as EventListener Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġ_ cin em as Ġ= ĠMed iator LiveData < List < C in ema >>() ĊĠĠĠ Ġval Ġcin em as : ĠLive Data < List < C in ema >> ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ cin em as ĊĊĠĠĠ Ġprivate Ġval Ġ_ switch To C in ema Detail Ġ= ĠMutable LiveData < Event < Int >>() ĊĠĠĠ Ġval Ġswitch To C in ema Detail : ĠLive Data < Event < Int >> ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ switch To C in ema Detail ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġload C in em as () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġload C in em as () Ġ{ ĊĠĠĠĠĠĠĠ Ġexecute ({ Ġcin ema Repository . getC in em as () Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ ĠonSuccess Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ_ cin em as . value Ġ= Ġit . cin em as ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ ĠonError Ġ= Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠNo - op ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon C in ema Clicked ( cin ema Id : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġpreferences Helper . save Selected C in ema Id ( cin ema Id ) ĊĠĠĠĠĠĠĠ Ġ_ switch To C in ema Detail . post Value ( Event ( cin ema Id )) ĊĠĠĠ Ġ} Ċ } Ċ Ċ interface ĠC in em as EventListener Ġ{ ĊĊĠĠĠ Ġfun Ġon C in ema Clicked ( cin ema Id : ĠInt ) Ċ Ċ }