package Ġcom . example . android . polit ical prepared ness . election Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroidx . lifecycle .* Ċ import Ġcom . example . android . polit ical prepared ness . database . E lection Database Ċ import Ġcom . example . android . polit ical prepared ness . network . models . E lection Ċ import Ġkotlinx . coroutines . launch Ċ Ċ // TODO ĠCOMP LETED : ĠConstruct ĠViewModel Ġand Ġprovide Ġelection Ġdatasource Ċ class ĠE lection s ViewModel ( application : ĠApplication ): ĠAndroid ViewModel ( application ) Ġ{ ĊĊĠĠĠ Ġ// TODO : ĠCreate Ġlive Ġdata Ġval Ġfor Ġupcoming Ġelection s ĊĠĠĠ Ġprivate Ġval Ġrepository Ġ= ĠE lection s Repository ( E lection Database . getInstance ( application )) ĊĊĠĠĠ Ġ// TODO ĠCOMP LETED : ĠCreate Ġlive Ġdata Ġval Ġfor Ġsaved Ġelection s ĊĠĠĠ Ġ// TODO ĠCOMP LETED : ĠCreate Ġval Ġand Ġfunctions Ġto Ġpopulate Ġlive Ġdata Ġfor Ġupcoming Ġelection s Ġfrom Ġthe ĠAPI Ġand Ġsaved Ġelection s Ġfrom Ġlocal Ġdatabase ĊĠĠĠ Ġval Ġelection s List : ĠLive Data < List < E lection >> Ġget () Ġ= Ġrepository . election s List ĊĠĠĠ Ġval Ġsaved Elect io ins List : ĠLive Data < List < E lection >> Ġget () Ġ= Ġrepository . saved Elect io ins List ĊĊĠĠĠ Ġinit { ĊĠĠĠĠĠĠĠ Ġrefresh Data () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġrefresh Data (){ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġrepository . apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrefresh E lection s () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// TODO ĠCOMP LETED : ĠCreate Ġfunctions Ġto Ġnavigate Ġto Ġsaved Ġor Ġupcoming Ġelection Ġvot er Ġinfo ĊĠĠĠ Ġprivate Ġval Ġ_ navigate To E lection Detail Ġ= ĠMutable LiveData < E lection >() ĊĠĠĠ Ġval Ġnavigate To E lection Detail ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ navigate To E lection Detail ĊĊĠĠĠ Ġfun Ġon E lection Item Clicked ( election : ĠE lection ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ navigate To E lection Detail . value Ġ= Ġelection ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġon E lection Item Navig ated () Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ navigate To E lection Detail . value Ġ= Ġnull ĊĠĠĠ Ġ} Ċ }