package Ġcom . hook ed roid . android architecture . character Ċ Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . Transform ations Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġcom . hook ed roid . android architecture . data . repository . Character Repository Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠCharacter Details ViewModel Ġ@ Inject Ġconstructor ( characters Repository : ĠCharacter Repository ) Ġ: ĠViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġcharacter Id Ġ= ĠMutable LiveData < Int >() ĊĊĠĠĠ Ġval Ġcharacter Ġ= ĠTransform ations . switch Map ( character Id ) Ġ{ Ġcharacters Repository . getById ( it ) Ġ} Ċ // ĠĠĠ Ġval Ġepisode s Ġ= ĠTransform ations . map ( character Id ) Ġ{ Ġepisode s Repository . getBy Character Id ( it ) Ġ} Ċ // ĠĠĠ Ġval Ġlocations Ġ= ĠTransform ations . map ( character Id ) Ġ{ Ġlocations Repository . getBy Character Id ( it ) Ġ} ĊĊĠĠĠ Ġfun Ġshow Character ( id : ĠInt ) Ġ{ ĊĠĠĠĠĠĠĠ Ġcharacter Id . value Ġ= Ġid ĊĠĠĠ Ġ} Ċ }