package Ġcom . example . weather app . ui . view model Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġcom . example . weather app . data . model . Weather Model Ċ import Ġcom . example . weather app . domain . Get Weather In My Location Ċ import Ġdagger . h ilt . android . lifecycle . H ilt ViewModel Ċ import Ġkotlinx . coroutines . launch Ċ import Ġjavax . inject . Inject Ċ Ċ @ H ilt ViewModel Ċ class ĠMy Location ViewModel Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġget Weather In My Location Ġ: ĠGet Weather In My Location Ċ ) Ġ: ĠViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġ_ weather Ġ= ĠMutable LiveData < Weather Model >() ĊĠĠĠ Ġval Ġweather : ĠLive Data < Weather Model > Ġ= Ġ_ weather ĊĊĠĠĠ Ġprivate Ġval Ġ_ isLoading Ġ= ĠMutable LiveData < Boolean >() ĊĠĠĠ Ġval ĠisLoading : ĠLive Data < Boolean > Ġ= Ġ_ isLoading ĊĊĠĠĠ Ġfun Ġupdate Weather ( lat : ĠDouble , Ġlon : ĠDouble , Ġforce Update : ĠBoolean Ġ= Ġfalse ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ isLoading . post Value ( true ) ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult Ġ= Ġget Weather In My Location ( lat , Ġlon , Ġforce Update ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġresult ?. also Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ_ weather . post Value ( it ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ_ isLoading . post Value ( false ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }