package Ġcom . github . p ids am hai . covid 1 9 th ail and . app widget Ċ Ċ import Ġandroid . content . SharedPreferences Ċ import Ġandroidx . core . content . edit Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġcom . github . p ids am hai . covid 1 9 th ail and . db . Result Ċ import Ġcom . github . p ids am hai . covid 1 9 th ail and . network . response . ddc . Today Ċ import Ġcom . github . p ids am hai . covid 1 9 th ail and . network . response . ddc . Today By Province Ċ import Ġcom . github . p ids am hai . covid 1 9 th ail and . repository . Repository Ċ import Ġcom . github . p ids am hai . covid 1 9 th ail and . utilities . get Widget Config Ċ import Ġcom . google . gson . Gson Ċ import Ġkotlinx . coroutines . flow . Flow Ċ import Ġtim ber . log . Tim ber Ċ Ċ class ĠTh ai Widget Configure VM ( ĊĠĠĠ Ġrepository : ĠRepository , ĊĠĠĠ Ġprivate Ġval Ġpref : ĠSharedPreferences Ċ ) Ġ: ĠViewModel () Ġ{ ĊĊĠĠĠ Ġval ĠdataSource : ĠFlow < Result < List < Today By Province >>> Ġ= Ġrepository . get Today By Pro vin ces ( true ) ĊĠĠĠ Ġval Ġtoday DataSource : ĠFlow < Result < Today >> Ġ= Ġrepository . get Today Flow () ĊĊĠĠĠ Ġfun Ġsave Widget Setting ( widget Id : ĠInt , Ġconfig : ĠWidget Config ) Ġ= Ġpref . edit Ġ{ ĊĠĠĠĠĠĠĠ Ġput String ( widget Id . toString (), ĠGson (). toJson ( config )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun ĠgetConfig ( widget Id : ĠInt ): ĠWidget Config ? Ġ{ ĊĠĠĠĠĠĠĠ ĠTim ber . d (" Get Config Ġ% s ", Ġwidget Id . toString ()) ĊĠĠĠĠĠĠĠ Ġreturn Ġpref . get Widget Config ( widget Id ) ĊĠĠĠ Ġ} Ċ Ċ }