package Ġcom . example . android . polit ical prepared ness . election Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġcom . example . android . polit ical prepared ness . E lection s Repository Ċ 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 Ċ Ċ // DONE : ĠConstruct ĠViewModel Ġand Ġprovide Ġelection Ġdatasource Ċ class ĠE lection s ViewModel ( application : ĠApplication ) Ġ: ĠViewModel () Ġ{ ĊĠĠĠ Ġ// DONE : ĠCreate Ġlive Ġdata Ġval Ġfor Ġupcoming Ġelection s ĊĠĠĠ Ġprivate Ġval Ġ_ up coming E lection s Ġ= ĠMutable LiveData < List < E lection >>() ĊĠĠĠ Ġval Ġupcoming E lection s : ĠLive Data < List < E lection >> ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ up coming E lection s ĊĊĠĠĠ Ġ// DONE : ĠCreate Ġlive Ġdata Ġval Ġfor Ġsaved Ġelection s ĊĊĠĠĠ Ġprivate Ġval Ġ_ navigate To V oter Info Ġ= ĠMutable LiveData < E lection >() ĊĠĠĠ Ġval Ġnavigate To V oter Info : ĠLive Data < E lection > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ navigate To V oter Info ĊĊĠĠĠ Ġprivate Ġval Ġelection Database Ġ= ĠE lection Database . getInstance ( application ) ĊĠĠĠ Ġprivate Ġval Ġelection s Repository Ġ= ĠE lection s Repository ( election Database ) ĊĊĠĠĠ Ġval Ġsaved E lection s Ġ= Ġelection s Repository . saved E lection s ĊĊĊĠĠĠ Ġ// TODO : ĠCreate Ġval Ġand Ġfunctions Ġto Ġpopulate Ġlive Ġdata Ġfor Ġupcoming Ġelection s Ġfrom Ġthe ĠAPI Ġand Ġsaved Ġelection s Ġfrom Ġlocal Ġdatabase ĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ up coming E lection s . value Ġ= Ġelection s Repository . get E lection s From Api () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// TODO : ĠCreate Ġfunctions Ġto Ġnavigate Ġto Ġsaved Ġor Ġupcoming Ġelection Ġvot er Ġinfo ĊĠĠĠ Ġfun Ġdisplay V oter Info ( election : ĠE lection ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ navigate To V oter Info . value Ġ= Ġelection ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġdisplay V oter Info Is Completed (){ ĊĠĠĠĠĠĠĠ Ġ_ navigate To V oter Info . value Ġ= Ġnull ĊĠĠĠ Ġ} ĊĊĊĊ Ċ }