package Ġz io x . ram iro . sa es . services Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . Binder Ċ import Ġandroid . widget . Adapter View Ċ import Ġandroid . widget . Remote Views Ċ import Ġandroid . widget . Remote Views Service Ċ import Ġandroidx . compose . ui . graphics . Color Ċ import Ġandroidx . compose . ui . graphics . to Argb Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġz io x . ram iro . sa es . R Ċ import Ġz io x . ram iro . sa es . data . repositories . Local App Database Ċ import Ġz io x . ram iro . sa es . features . sa es . features . schedule . data . models . Class Schedule Ċ import Ġz io x . ram iro . sa es . features . sa es . features . schedule . data . models . Week Day ĊĊ Ċ /** Ċ Ġ* ĠC read o Ġpor ĠRam iro Ġel Ġ 1 5 / 0 4 / 2 0 1 9 Ġa Ġlas Ġ 0 3 : 3 3 ĠPM Ġpara ĠS AES v 2 . Ċ Ġ*/ Ċ class ĠList Widget Remote Views Factory Ġ( val Ġcontext : ĠContext , Ġval Ġintent : ĠIntent ) Ġ: ĠRemote Views Service . Remote Views Factory Ġ{ ĊĠĠĠ Ġprivate Ġval Ġschedule Data Ġ= Ġmutable ListOf < Class Schedule >() ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate () Ġ{ ĊĠĠĠĠĠĠĠ Ġfetch Schedule Data () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Loading View (): ĠRemote Views ? Ġ= Ġnull ĊĊĠĠĠ Ġoverride Ġfun ĠgetItem Id ( position : ĠInt ) Ġ= Ġschedule Data . get OrNull ( position )?. id ?. hashCode ()?. to Long () Ġ?: Ġ- 1 ĊĊĠĠĠ Ġoverride Ġfun Ġon DataSet Changed () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġid Token Ġ= ĠB inder . clear Calling Identity () ĊĊĠĠĠĠĠĠĠ Ġfetch Schedule Data () ĊĊĠĠĠĠĠĠĠ ĠB inder . restore Calling Identity ( id Token ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġhas Stable Ids (): ĠBoolean Ġ= Ġtrue ĊĊĠĠĠ Ġoverride Ġfun Ġget View At ( position : ĠInt ): ĠRemote Views ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġclass Schedule Ġ= Ġschedule Data . get OrNull ( position ) ĊĊĠĠĠĠĠĠĠ Ġif Ġ( position Ġ== ĠAdapter View . INVALID _ POSITION Ġ|| Ġschedule Data . isEmpty () Ġ|| Ġclass Schedule Ġ== Ġnull ) Ġreturn Ġnull ĊĊĠĠĠĠĠĠĠ Ġval Ġremote Views Ġ= ĠRemote Views ( context . packageName , ĠR . layout . widget _ schedule _ medium _ item ) ĊĊĠĠĠĠĠĠĠ Ġremote Views . setInt ( R . id . widget H ora Parent , Ġ" set BackgroundColor ", ĠColor ( class Schedule . color . to UL ong ()). to Argb ()) ĊĠĠĠĠĠĠĠ Ġremote Views . setText View Text ( R . id . course _ name _ text _ view , Ġclass Schedule . className ) ĊĠĠĠĠĠĠĠ Ġremote Views . setText View Text ( R . id . widget H ora Inicio , Ġclass Schedule . schedule Day Time . start . toString ()) ĊĠĠĠĠĠĠĠ Ġremote Views . setText View Text ( R . id . widget H ora Final , Ġclass Schedule . schedule Day Time . end . toString ()) ĊĠĠĠĠĠĠĠ Ġremote Views . setText View Text ( R . id . teacher _ name _ text _ view , Ġclass Schedule . teacher Name ) ĊĠĠĠĠĠĠĠ Ġremote Views . setText View Text ( R . id . building _ name _ text _ view , Ġclass Schedule . building ) ĊĠĠĠĠĠĠĠ Ġremote Views . setText View Text ( R . id . class _ room _ name _ text _ view , Ġclass Schedule . class room ) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġremote Views ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Count () Ġ= Ġschedule Data . size ĊĊĠĠĠ Ġoverride Ġfun Ġon Destroy () Ġ{} ĊĊĠĠĠ Ġoverride Ġfun Ġget ViewType Count (): ĠInt Ġ= Ġ 1 ĊĊĠĠĠ Ġprivate Ġfun Ġfetch Schedule Data (){ ĊĠĠĠĠĠĠĠ Ġval Ġdb Ġ= ĠLocal App Database ( context ). schedule Repository () ĊĠĠĠĠĠĠĠ Ġval Ġschedule List Ġ= Ġrun Blocking ( Dispatch ers . Default ){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdb . get My Schedule () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġweek Day Ġ= ĠWeek Day . today () ĊĊĠĠĠĠĠĠĠ Ġschedule Data . clear () ĊĠĠĠĠĠĠĠ Ġschedule Data . addAll ( schedule List . filter Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . schedule Day Time . week Day Ġ== Ġweek Day ĊĠĠĠĠĠĠĠ Ġ}. sorted By Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . schedule Day Time . start . toDouble () ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} Ċ }