package Ġcom . little c org i . course ji . schedule . vm Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroidx . lifecycle . Android ViewModel Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġcom . little c org i . course ji . App Database Ċ import Ġcom . little c org i . course ji . R Ċ import Ġcom . little c org i . course ji . schedule . logic . model . bean . Course Bean Ċ import Ġcom . little c org i . course ji . schedule . logic . model . bean . Table Bean Ċ import Ġcom . little c org i . course ji . schedule . logic . model . bean . Time Detail Bean Ċ Ċ /** Ċ Ġ* Ġ è¯¾ç¨ĭ ViewModel Ċ Ġ* Ġ@ author Ġlittle c org i Ġ 2 0 2 0 / 1 2 / 2 6 Ċ Ġ*/ Ċ class ĠSchedule ViewModel ( application : ĠApplication ) Ġ: ĠAndroid ViewModel ( application ) Ġ{ ĊĊĠĠĠ Ġval Ġm Header ImageUrl Ġ= ĊĠĠĠĠĠĠĠ Ġ" https :// t img sa . baidu . com / t img ? image & quality = 8 0 & size = b 9 9 9 9 _ 1 0 0 0 0 & sec = 1 6 0 3 1 9 0 1 7 6 3 7 8 & di = 2 6 e 4 1 0 9 c 7 a 9 fa 3 2 4 1 8 0 f 9 de ab 9 e 8 e 5 9 5 & img type = 0 & src = http % 3 A % 2 F % 2 F di k . img . k ttp dq . com % 2 F pic % 2 F 7 0 % 2 F 4 8 5 5 8 % 2 F 2 ca 2 3 8 5 f 8 d 0 4 b 4 a 5 . jpg " ĊĠĠĠ Ġval Ġm Bg ImageUrl Ġ= ĊĠĠĠĠĠĠĠ Ġ" https :// t img sa . baidu . com / t img ? image & quality = 8 0 & size = b 9 9 9 9 _ 1 0 0 0 0 & sec = 1 6 0 3 1 9 0 4 0 6 7 0 0 & di = 8 3 c 7 6 2 b 9 8 8 4 8 6 2 2 7 0 c 9 8 e 3 f 2 b 1 3 2 6 2 8 6 & img type = 0 & src = http % 3 A % 2 F % 2 F attach . bbs . mi ui . com % 2 F forum % 2 F 2 0 1 5 0 4 % 2 F 0 2 % 2 F 1 4 0 3 0 8 w 5 n 0 nz 3 ns 9 b 3 bb zj . png " ĊĊĠĠĠ Ġprivate Ġval Ġdata Base Ġ= ĠApp Database . get Database ( application ) ĊĠĠĠ Ġprivate Ġval Ġcourse Dao Ġ= Ġdata Base . course Dao () ĊĠĠĠ Ġprivate Ġval Ġtable Dao Ġ= Ġdata Base . table Dao () ĊĠĠĠ Ġprivate Ġval Ġtime Table Dao Ġ= Ġdata Base . time Table Dao () ĊĠĠĠ Ġprivate Ġval Ġtime Dao Ġ= Ġdata Base . time Detail Dao () ĊĊĠĠĠ Ġ// Ġä½¿çĶ¨ æŃ¤ å±ŀæĢ§ æĹ¶ è¯· åĬ¡ å¿ħ ä¿Ŀè¯ģ ä½¿çĶ¨ é¡ºåºı ä½į äºİ MainActivity . init Week Toggle Group () ä¹ĭåĲİ ĊĠĠĠ Ġ// Ġ åĽłä¸º è¿Ļä¸ª æĹ¶åĢĻ æĪĳä»¬ æīį åľ¨ åĪĿå§ĭåĮĸ table ĊĠĠĠ Ġlateinit Ġvar Ġtable : ĠTable Bean ĊĠĠĠ Ġlateinit Ġvar Ġtime List : ĠList < Time Detail Bean > ĊĠĠĠ Ġvar Ġselected Week Ġ= Ġ 1 ĊĠĠĠ Ġval Ġmar Top Ġ= Ġapplication . resources . get Dimension Pixel Size ( R . dim en . week Item Mar Top ) ĊĠĠĠ Ġvar Ġitem Height Ġ= Ġ 0 ĊĠĠĠ Ġvar Ġalpha Int Ġ= Ġ 2 2 5 ĊĠĠĠ Ġval Ġall Course List Ġ= ĠArray ( 7 ) Ġ{ ĠMutable LiveData < List < Course Bean >>() Ġ} ĊĠĠĠ Ġval Ġdays Array Ġ= ĠarrayOf (" æĹ¥ ", Ġ" ä¸Ģ ", Ġ" äºĮ ", Ġ" ä¸ī ", Ġ" åĽĽ ", Ġ" äºĶ ", Ġ" åħŃ ", Ġ" æĹ¥ ") ĊĠĠĠ Ġvar Ġcurrent Week Ġ= Ġ 1 ĊĊĠĠĠ Ġsuspend Ġfun ĠgetDefault Table (): ĠTable Bean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġtable Dao . getDefault Table () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsuspend Ġfun ĠgetTime List ( time Table Id : ĠInt ): ĠList < Time Detail Bean > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġtime Dao . getTime List ( time Table Id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Raw Course By Day ( day : ĠInt , Ġtable Id : ĠInt ): ĠLive Data < List < Course Bean >> Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġcourse Dao . getC ourse By Day Of Table LiveData ( day , Ġtable Id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Show Course Number ( week : ĠInt ): ĠLive Data < Int > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġif Ġ( table . show Other Week Course ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Dao . get Show Course Number With Other Week ( table . id , Ġweek ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcourse Dao . get Show Course Number ( table . id , Ġweek ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ