package Ġcom . real it ix . meal assistant Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . input method . Input Method Manager Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroidx . navigation . Navigation . find Nav Controller Ċ import Ġandroidx . navigation . ui . setup With Nav Controller Ċ import Ġandroidx . work .* Ċ import Ġcom . real it ix . meal assistant . command . Ali ment Updater Ċ import Ġcom . real it ix . meal assistant . work . Ali ment Updater Worker Ċ import Ġkotlinx . android . synt hetic . main . activity _ main .* Ċ import Ġkotlinx . coroutines . Global Scope Ċ import Ġkotlinx . coroutines . launch Ċ import Ġjava . time . Duration ĊĊ Ċ class ĠMainActivity : ĠAppCompatActivity () Ġ{ ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( R . layout . activity _ main ) ĊĠĠĠĠĠĠĠ Ġnavigation . setup With Nav Controller ( find Nav Controller ( this , ĠR . id . nav _ host _ fragment )) ĊĊĠĠĠĠĠĠĠ Ġstart Ali ment Updater Worker () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġstart Ali ment Updater Worker () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġconstraints Ġ= ĠConstraints . Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Requires Storage Not Low ( true ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠĠĠĠĠ Ġval Ġal iment Updater Work Ġ= ĠOne Time Work RequestBuilder < Ali ment Updater Worker >() ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Constraints ( constraints ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĊĠĠĠĠĠĠĠ ĠWork Manager . getInstance ( this ). enqueue ( al iment Updater Work ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Support Navigate Up () Ġ= Ġfind Nav Controller ( this , ĠR . id . nav _ host _ fragment ). navigate Up () ĊĊĠĠĠ Ġfun Ġtoggle Keyboard () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġimm Ġ= Ġget System Service ( Context . INPUT _ METHOD _ SERVICE ) Ġas ? ĠInput Method Manager ĊĠĠĠĠĠĠĠ Ġimm !!. toggle Soft Input ( Input Method Manager . HIDE _ IMP LICIT _ ONLY , Ġ 0 ) ĊĠĠĠ Ġ} Ċ } Ċ