package Ġcom . example . android . polit ical prepared ness . represent ative Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ import Ġcom . example . android . polit ical prepared ness . election . V oter Info Fragment Args Ċ import Ġcom . example . android . polit ical prepared ness . election . V oter Info ViewModel Ċ import Ġcom . example . android . polit ical prepared ness . repository . E lection Repository Ċ import Ġjava . lang . IllegalArgumentException Ċ Ċ class ĠRepresent ative ViewModel Factory ( private Ġval Ġrepository : ĠRep Repository ): ĠViewModel Provider . Factory Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġ< T Ġ: ĠViewModel ?> Ġcreate ( model Class : ĠClass < T >): ĠT Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( model Class . isAssignableFrom ( Represent ative ViewModel :: class . java )){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠRepresent ative ViewModel ( repository ) Ġas ĠT ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġthrow ĠIllegalArgumentException (" Unknown ĠView model Ġclass ") ĊĠĠĠ Ġ} Ċ Ċ }