package Ġcom . example . android . polit ical prepared ness . election Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroid . content . Context Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġcom . example . android . polit ical prepared ness . database . E lection Dao Ċ import Ġcom . example . android . polit ical prepared ness . database . E lection Database Ċ import Ġcom . example . android . polit ical prepared ness . network . C iv ics Api Ċ import Ġcom . example . android . polit ical prepared ness . network . C iv ics ApiService Ċ import Ġjava . lang . Append able Ċ Ċ // TODO ĠCOMP LETED : ĠCreate ĠFactory Ġto Ġgenerate ĠE lection ViewModel Ġwith Ġprovided Ġelection Ġdatasource Ċ class ĠE lection s ViewModel Factory ( private Ġval Ġcontext : ĠApplication ) Ġ: ĠViewModel Provider . Factory Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġ< T Ġ: ĠViewModel ?> Ġcreate ( model Class : ĠClass < T >): ĠT Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( model Class . isAssignableFrom ( E lection s ViewModel :: class . java )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠE lection s ViewModel ( context ) Ġas ĠT ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġthrow ĠIllegalArgumentException (" Unknown ĠViewModel Ġclass ") ĊĠĠĠ Ġ} Ċ }