package Ġcom . zi em app . john zi eman . m yst ory book . view models Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . Transform ations Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġcom . zi em app . john zi eman . m yst ory book . Story book Repository Ċ import Ġcom . zi em app . john zi eman . m yst ory book . models . Story Ċ import Ġjava . io . File Ċ import Ġjava . util .* Ċ Ċ class ĠStory book Details ViewModel : ĠViewModel () Ġ{ ĊĠĠĠ Ġprivate Ġval Ġstory book Repository Ġ= ĠStory book Repository . get () ĊĠĠĠ Ġprivate Ġval Ġstory Id Live Date Ġ= ĠMutable LiveData < UUID >() ĊĊĠĠĠ Ġval Ġstory LiveData : ĠLive Data < Story ?> Ġ= ĠTransform ations . switch Map ( story Id Live Date ){ ĊĠĠĠĠĠĠĠ Ġstory Id -> Ġstory book Repository . get Story ( story Id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġload Story ( story Id : ĠUUID ){ ĊĠĠĠĠĠĠĠ Ġstory Id Live Date . value Ġ= Ġstory Id ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġsave Story ( story : ĠStory ){ ĊĠĠĠĠĠĠĠ Ġstory book Repository . update Story ( story ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġfun Ġdelete Story ( story : ĠStory ){ ĊĠĠĠĠĠĠĠ Ġstory book Repository . delete Story ( story ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Photo File ( story : ĠStory ): ĠFile Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġstory book Repository . get Photo File ( story ) ĊĠĠĠ Ġ} Ċ }