package Ġcom . k yle cor ry . trail _ sense . weather . infrastructure Ċ Ċ import Ġandroid . content . Context Ċ import Ġcom . k yle cor ry . trail _ sense . shared . User Preferences Ċ import Ġcom . k yle cor ry . trail _ sense . weather . infrastructure . re ceiv ers . Weather Update Alarm Receiver Ċ import Ġcom . k yle cor ry . trail _ sense . weather . infrastructure . services . Weather Update Service Ċ import Ġcom . k yle cor ry . tr ails ense core . infrastructure . system . Notification Utils Ċ import Ġcom . k yle cor ry . tr ails ense core . infrastructure . tasks . IT ask Scheduler Ċ import Ġjava . time . Duration Ċ Ċ object ĠWeather Update Scheduler Ġ{ ĊĠĠĠ Ġfun Ġstart ( context : ĠContext ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġscheduler Ġ= Ġget Scheduler ( context ) ĊĠĠĠĠĠĠĠ Ġscheduler . schedule ( Duration . ZERO ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġstop ( context : ĠContext ) Ġ{ ĊĠĠĠĠĠĠĠ ĠNotification Utils . cancel ( context , ĠWeather Notification Service . WE ATHER _ NOTIFICATION _ ID ) ĊĠĠĠĠĠĠĠ Ġval Ġscheduler Ġ= Ġget Scheduler ( context ) ĊĠĠĠĠĠĠĠ Ġscheduler . cancel () ĊĠĠĠĠĠĠĠ Ġcontext . stop Service ( Weather Update Service . intent ( context )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Scheduler ( context : ĠContext ): ĠI Task Scheduler Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġprefs Ġ= ĠUser Preferences ( context ) ĊĠĠĠĠĠĠĠ Ġreturn Ġif Ġ( prefs . weather . force Weather Updates ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠWeather Update Alarm Receiver . scheduler ( context ) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠWeather Update Worker . scheduler ( context ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }