package Ġcom . am it . reward store . ui . view model Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġcom . am it . reward store . repository . Rewards Repository Ċ import Ġcom . am it . reward store . repository . models . Reward Description Ċ import Ġcom . am it . reward store . repository . models . Reward Item Ċ import Ġdagger . h ilt . android . lifecycle . H ilt ViewModel Ċ import Ġkotlinx . coroutines .* Ċ import Ġjavax . inject . Inject Ċ Ċ @ H ilt ViewModel Ċ class ĠRew ard Detail ViewModel Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġrewards Repository : ĠRew ards Repository Ċ ) Ġ: ĠViewModel () Ġ{ ĊĠĠĠ Ġprivate Ġval ĠviewModel Coroutine Context Ġ= ĠSuper visor Job () Ġ+ ĠDispatch ers . Main ĊĠĠĠ Ġprivate Ġval ĠviewModel Scope Ġ= ĠCor outine Scope ( viewModel Coroutine Context ) ĊĠĠĠ Ġvar Ġreward Id : ĠString ? Ġ= Ġnull ĊĊĠĠĠ Ġprivate Ġval Ġ_ reward : ĠMutable LiveData < Reward Item > Ġ= ĠMutable LiveData () ĊĠĠĠ Ġval Ġreward : ĠLive Data < Reward Item > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ reward ĊĊĠĠĠ Ġprivate Ġval Ġ_ reward Detail : ĠMutable LiveData < Reward Description > Ġ= ĠMutable LiveData () ĊĠĠĠ Ġval Ġreward Description : ĠLive Data < Reward Description > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ reward Detail ĊĊĠĠĠ Ġfun Ġload Reward Detail () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġreward Id Ġ= Ġthis . reward Id Ġ?: Ġreturn ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwith Context ( Dispatch ers . IO ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġreward Ġ= Ġrewards Repository . get Reward ( reward Id ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpost Reward Item ( reward ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġreward Detail Ġ= Ġrewards Repository . get Reward Description ( reward Id ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpost Reward Detail ( reward Detail ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġsuspend Ġfun Ġpost Reward Detail ( reward Detail : ĠRew ard Description ) Ġ= ĊĠĠĠĠĠĠĠ Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ reward Detail . post Value ( reward Detail ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġsuspend Ġfun Ġpost Reward Item ( reward : ĠRew ard Item ) Ġ= Ġwith Context ( Dispatch ers . Main ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ reward . post Value ( reward ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Cle ared () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Cle ared () ĊĠĠĠĠĠĠĠ ĠviewModel Scope . cancel (" View Ġmodel Ġcleared ") ĊĠĠĠ Ġ} Ċ }