package Ġcom . de let _ dis . element ary launcher . presentation . views . clock View . viewModel čĊč Ċ import Ġandroid . app . Application č Ċ import Ġandroidx . lifecycle . Android ViewModel č Ċ import Ġandroidx . lifecycle . LiveData č Ċ import Ġandroidx . lifecycle . Mutable LiveData č Ċ import Ġcom . de let _ dis . element ary launcher . data . broadcast Re ceiv ers . Alarm Changed Broadcast Receiver č Ċ import Ġcom . de let _ dis . element ary launcher . data . broadcast Re ceiv ers . Date And Time Changed Broadcast Receiver č Ċ import Ġcom . de let _ dis . element ary launcher . domain . helpers . format To Digital Clock č Ċ import Ġcom . de let _ dis . element ary launcher . domain . helpers . getCurrent Date č Ċ import Ġcom . de let _ dis . element ary launcher . domain . helpers . getCurrent Time č Ċ import Ġcom . de let _ dis . element ary launcher . domain . repositories . Al arms Repository č Ċ import Ġdagger . Module č Ċ import Ġdagger . h ilt . Install In č Ċ import Ġdagger . h ilt . components . Singleton Component č Ċ import Ġjavax . inject . Inject čĊč Ċ @ Module č Ċ @ Install In ( Singleton Component :: class ) č Ċ class ĠClock View ViewModel Ġ@ Inject Ġconstructor ( čĊĠĠĠ Ġapplication : ĠApplication , čĊĠĠĠ Ġprivate Ġval Ġal arms Repository : ĠAl arms Repository č Ċ ) Ġ: ĠAndroid ViewModel ( application ) Ġ{ čĊčĊĠĠĠ Ġprivate Ġval Ġ_ date LiveData Ġ= ĠMutable LiveData ( getCurrent Date ()) čĊĠĠĠ Ġval Ġdate LiveData : ĠLive Data < String > čĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ date LiveData čĊčĊĠĠĠ Ġprivate Ġval Ġ_ time LiveData Ġ= ĠMutable LiveData ( getCurrent Time ()) čĊĠĠĠ Ġval Ġtime LiveData : ĠLive Data < String > čĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ time LiveData čĊčĊĠĠĠ Ġprivate Ġval Ġ_ is Alarm Enabled Ġ= ĠMutable LiveData ( Al arms Repository ( getApplication ()). is Alarm Enabled ) čĊĠĠĠ Ġval Ġis Alarm Enabled : ĠLive Data < Boolean > čĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ is Alarm Enabled čĊčĊĠĠĠ Ġprivate Ġval Ġ_ next Alarm Trigger Time Ġ= čĊĠĠĠĠĠĠĠ ĠMutable LiveData ( al arms Repository . next Alarm ?. let Ġ{ Ġnext Alarm Time Ġ-> čĊĠĠĠĠĠĠĠĠĠĠĠ Ġformat To Digital Clock ( čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnext Alarm Time čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) čĊĠĠĠĠĠĠĠ Ġ}) čĊĠĠĠ Ġval Ġnext Alarm Trigger Time : ĠLive Data < String > čĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ next Alarm Trigger Time čĊčĊĠĠĠ Ġinit Ġ{ čĊĠĠĠĠĠĠĠ Ġinit Date And Time Broadcast Receiver () čĊĠĠĠĠĠĠĠ Ġinit Alarm Changed Broadcast Receiver () čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġprivate Ġfun Ġinit Date And Time Broadcast Receiver () Ġ{ čĊĠĠĠĠĠĠĠ Ġval Ġdate And Time Changed Broadcast Receiver Ġ= Ġobject Ġ: ĠDate And Time Changed Broadcast Receiver () Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Time Tick () Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ_ date LiveData . post Value ( getCurrent Date ()) čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ_ time LiveData . post Value ( getCurrent Time ()) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} čĊĠĠĠĠĠĠĠ Ġ} čĊčĊĠĠĠĠĠĠĠ Ġget Application < Application >(). register Receiver ( čĊĠĠĠĠĠĠĠĠĠĠĠ Ġdate And Time Changed Broadcast Receiver , čĊĠĠĠĠĠĠĠĠĠĠĠ ĠDate And Time Changed Broadcast Receiver . intent Filter čĊĠĠĠĠĠĠĠ Ġ) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġprivate Ġfun Ġinit Alarm Changed Broadcast Receiver () Ġ{ čĊĠĠĠĠĠĠĠ Ġval Ġalarm Changed Broadcast Receiver Ġ= Ġobject Ġ: ĠAlarm Changed Broadcast Receiver () Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Alarm Changed () Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ_ next Alarm Trigger Time . post Value ( al arms Repository čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. next Alarm ?. let Ġ{ Ġnext Alarm Time Ġ-> čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġformat To Digital Clock ( čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnext Alarm Time čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) čĊčĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ}) čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ_ is Alarm Enabled . post Value ( al arms Repository . is Alarm Enabled ) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} čĊĠĠĠĠĠĠĠ Ġ} čĊčĊĠĠĠĠĠĠĠ Ġget Application < Application >(). register Receiver ( čĊĠĠĠĠĠĠĠĠĠĠĠ Ġalarm Changed Broadcast Receiver , čĊĠĠĠĠĠĠĠĠĠĠĠ ĠAlarm Changed Broadcast Receiver . intent Filter čĊĠĠĠĠĠĠĠ Ġ) čĊĠĠĠ Ġ} č Ċ } čĊ