package Ġfr . core nt ing . ed comp anion . view _ models čĊč Ċ import Ġandroid . app . Application č Ċ import Ġandroidx . lifecycle . Android ViewModel č Ċ import Ġandroidx . lifecycle . LiveData č Ċ import Ġandroidx . lifecycle . Mutable LiveData č Ċ import Ġandroidx . lifecycle . viewModel Scope č Ċ import Ġfr . core nt ing . ed comp anion . models . Proxy Result č Ċ import Ġfr . core nt ing . ed comp anion . models . Systems Distance č Ċ import Ġfr . core nt ing . ed comp anion . network . Distance Calculator Network č Ċ import Ġkotlinx . coroutines . launch čĊč Ċ class ĠDistance Calculator ViewModel ( application : ĠApplication ) Ġ: ĠAndroid ViewModel ( application ) Ġ{ čĊĠĠĠ Ġprivate Ġval Ġdistance Calculation Result Ġ= ĠMutable LiveData < Proxy Result < Systems Distance >>() čĊčĊĠĠĠ Ġfun Ġcompute Distance Between Systems ( first System Name : ĠString , Ġsecond System Name : ĠString ) Ġ{ čĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠ Ġdistance Calculation Result . post Value ( čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠDistance Calculator Network . get Distance ( čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġget Application (), čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfirst System Name , čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġsecond System Name čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) čĊĠĠĠĠĠĠĠ Ġ} čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġfun Ġget Distance Between Systems Result (): ĠLive Data < Proxy Result < Systems Distance >> Ġ{ čĊĠĠĠĠĠĠĠ Ġreturn Ġdistance Calculation Result čĊĠĠĠ Ġ} č Ċ }