package Ġcn . edu . bu pt . countdown . event _ app widget Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroidx . lifecycle . Android ViewModel Ċ import Ġcn . edu . bu pt . countdown . App Database Ċ import Ġcn . edu . bu pt . countdown . bean . Event Bean Ċ import Ġcn . edu . bu pt . countdown . bean . Single App Widget Bean Ċ Ċ class ĠApp Widget Configure ViewModel ( application : ĠApplication ) Ġ: ĠAndroid ViewModel ( application ) Ġ{ ĊĊĠĠĠ Ġvar Ġselected Event : ĠEvent Bean ? Ġ= Ġnull ĊĠĠĠ Ġvar Ġwidget Bean Ġ= ĠSingle App Widget Bean () ĊĠĠĠ Ġval Ġshow List Ġ= Ġarray ListOf < Event Bean >() ĊĠĠĠ Ġprivate Ġval Ġdata Base Ġ= ĠApp Database . get Database ( application ) ĊĠĠĠ Ġprivate Ġval Ġevent Dao Ġ= Ġdata Base . event Dao () ĊĠĠĠ Ġprivate Ġval Ġwidget Dao Ġ= Ġdata Base . single Widget Dao () ĊĊĠĠĠ Ġsuspend Ġfun ĠgetAll Events (): ĠList < Event Bean > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġevent Dao . getAll In Thread () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsuspend Ġfun Ġinsert Widget () Ġ{ ĊĠĠĠĠĠĠĠ Ġwidget Dao . insert ( widget Bean ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsuspend Ġfun Ġupdate Widget () Ġ{ ĊĠĠĠĠĠĠĠ Ġwidget Dao . update ( widget Bean ) ĊĠĠĠ Ġ} Ċ }