package Ġcom . erm . artists . ui . favorite Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġcom . erm . artists . data . model . entity . Artist Ċ import Ġcom . erm . artists . data . repository . Artist Repository Ċ import Ġcom . erm . artists . ui . base . Base ViewModel Ċ import Ġcom . erm . artists . ui . base . State ful Resource Ċ import Ġkotlinx . coroutines . launch Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠF avorite Art ists Fragment ViewModel Impl Ċ @ Inject Ċ constructor ( ĊĠĠĠ Ġprivate Ġval Ġbands In Town Artist Repository : ĠArtist Repository Ċ ) Ġ: ĠBase ViewModel (), ĠF avorite Art ists Fragment ViewModel Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġfavorite Art ists Ġ= ĠMutable LiveData < State ful Resource < List < Artist >? >>() ĊĠĠĠ Ġoverride Ġfun Ġget Favorite Art ists (): ĠLive Data < State ful Resource < List < Artist >? >> Ġ= Ġfavorite Art ists ĊĊĠĠĠ Ġprivate Ġvar Ġlast Artist Id Removed From F avorites : ĠLong ? Ġ= Ġnull ĊĠĠĠ Ġoverride Ġfun Ġundo Favorite Artist Removal () Ġ{ ĊĠĠĠĠĠĠĠ Ġlast Artist Id Removed From F avorites ?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġbands In Town Artist Repository . add Favorite Artist ( it ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġlast Artist Id Removed From F avorites Ġ= Ġnull ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġun Favorite Artist ( artist : ĠArtist ) Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlast Artist Id Removed From F avorites Ġ= Ġartist . id ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbands In Town Artist Repository . delete Favorite Artist ( artist . id !! ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġrefresh Data () Ġ{ ĊĠĠĠĠĠĠĠ Ġlaunch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfavorite Art ists . value Ġ= ĠStateful Resource . with ( State ful Resource . State . LOADING ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfavorite Art ists . value Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠStateful Resource . success ( bands In Town Artist Repository . get Favorite Art ists ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }