package Ġcom . tern ary op . photos he lf . activity Ċ Ċ import Ġandroid . content . SharedPreferences Ċ import Ġandroid . net . Uri Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mediator LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġcom . tern ary op . photos he lf . birthday . repository . Birth day Repository Ċ import Ġcom . tern ary op . photos he lf . core . prefs . fetch Blog Names Ċ import Ġcom . tern ary op . photos he lf . lifecycle . Command Ċ import Ġcom . tern ary op . photos he lf . lifecycle . Event Ċ import Ġcom . tern ary op . photos he lf . repository . tum blr . T um blr Repository Ċ import Ġdagger . h ilt . android . lifecycle . H ilt ViewModel Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . launch Ċ import Ġjavax . inject . Inject Ċ Ċ @ H ilt ViewModel Ċ class ĠMainActivity ViewModel Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġshared Preferences : ĠSharedPreferences , ĊĠĠĠ Ġprivate Ġval Ġbirthday Repository : ĠB irth day Repository , ĊĠĠĠ Ġprivate Ġval Ġt um blr Repository : ĠT um blr Repository Ċ ) Ġ: ĠViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġ_ result Ġ= ĠMed iator LiveData < Event < MainActivity Model Result >>() ĊĠĠĠ Ġval Ġresult : ĠLive Data < Event < MainActivity Model Result >> Ġ= Ġ_ result ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ result . add Source ( tum blr Repository . draft Count ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ result . value Ġ= ĠEvent ( MainActivity Model Result . Draft Count ( it )) Ġ} ĊĠĠĠĠĠĠĠ Ġ_ result . add Source ( tum blr Repository . scheduled Count ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ result . value Ġ= ĠEvent ( MainActivity Model Result . Scheduled Count ( it )) Ġ} ĊĠĠĠĠĠĠĠ Ġ_ result . add Source ( tum blr Repository . authenticate ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ result . value Ġ= ĠEvent ( MainActivity Model Result . T um blr Authenticated ( it )) Ġ} ĊĠĠĠĠĠĠĠ Ġ_ result . add Source ( birthday Repository . count ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ result . value Ġ= ĠEvent ( MainActivity Model Result . Birth days Count ( it )) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġdraft Count ( blog Name : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch ( Dispatch ers . IO ) Ġ{ Ġt um blr Repository . draft Count ( blog Name ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġscheduled Count ( blog Name : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch ( Dispatch ers . IO ) Ġ{ Ġt um blr Repository . scheduled Count ( blog Name ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġbirth days Count () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch ( Dispatch ers . IO ) Ġ{ Ġbirthday Repository . count () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġfetch Blog Names () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġcommand Ġ= ĠCommand . execute Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġshared Preferences . fetch Blog Names ( tum blr Repository . tum blr ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ result . post Value ( Event ( MainActivity Model Result . Blog Names ( command ))) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġhandle Callback T um blr Uri ( uri : ĠUri ?) Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch ( Dispatch ers . IO ) Ġ{ Ġt um blr Repository . handle Callback Uri ( uri ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġclear Counters () Ġ{ ĊĠĠĠĠĠĠĠ Ġbirthday Repository . clear Count () ĊĠĠĠĠĠĠĠ Ġt um blr Repository . clear Count () ĊĠĠĠ Ġ} Ċ } Ċ Ċ sealed Ġclass ĠMainActivity Model Result Ġ{ ĊĠĠĠ Ġclass ĠDraft Count ( val Ġcommand : ĠCommand < Int >) Ġ: ĠMainActivity Model Result () ĊĠĠĠ Ġclass ĠScheduled Count ( val Ġcommand : ĠCommand < Int >) Ġ: ĠMainActivity Model Result () ĊĠĠĠ Ġclass ĠB irth days Count ( val Ġcommand : ĠCommand < Int >) Ġ: ĠMainActivity Model Result () ĊĠĠĠ Ġclass ĠBlog Names ( val Ġcommand : ĠCommand < List < String >>) Ġ: ĠMainActivity Model Result () ĊĠĠĠ Ġclass ĠT um blr Authenticated ( val Ġcommand : ĠCommand < Boolean >) Ġ: ĠMainActivity Model Result () Ċ } Ċ