package Ġcom . github . ser g ere in ov . aa 2 0 2 0 Ċ Ċ import Ġandroid . app . Application Ċ import Ġandroidx . work .* Ċ import Ġcom . github . ser g ere in ov . aa 2 0 2 0 . database . Movie Database Ċ import Ġcom . github . ser g ere in ov . aa 2 0 2 0 . domain .* Ċ import Ġcom . github . ser g ere in ov . aa 2 0 2 0 . network . IN etwork Interactor Ċ import Ġcom . github . ser g ere in ov . aa 2 0 2 0 . network . Network Module Ċ import Ġcom . github . ser g ere in ov . aa 2 0 2 0 . worker . Movies Worker Factory Ċ import Ġcom . github . ser g ere in ov . aa 2 0 2 0 . worker . Work Requests Ċ Ċ class ĠMov ies Application Ġ: ĠApplication (), ĠConfiguration . Provider , ĠInter actors Provider Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġnetwork Module : ĠIN etwork Interactor ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdatabase : ĠMovie Database ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġnotifications : ĠNotifications ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate () ĊĊĠĠĠĠĠĠĠ Ġnetwork Module Ġ= ĠNetwork Module ( application Context ) ĊĠĠĠĠĠĠĠ Ġdatabase Ġ= ĠMovie Database . create ( application Context ) ĊĠĠĠĠĠĠĠ Ġnotifications Ġ= ĠAndroid Notifications ( application Context ) ĊĊĠĠĠĠĠĠĠ Ġval Ġwork Manager Ġ= ĠWork Manager . getInstance ( application Context ) ĊĠĠĠĠĠĠĠ Ġ// work Manager . enqueue ( Work Requests . refresh Movies Now ) Ġ// un comment Ġto Ġtest / debug Ġworker ĊĠĠĠĠĠĠĠ Ġwork Manager . enqueue Unique Periodic Work ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" refresh Movies Periodic ", ĊĠĠĠĠĠĠĠĠĠĠĠ ĠExisting Periodic Work Policy . KEEP , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠWork Requests . refresh Movies Periodic ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Work Manager Configuration (): ĠConfiguration Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmovies Worker Factory Ġ= ĠDeleg ating Worker Factory () ĊĠĠĠĠĠĠĠ Ġmovies Worker Factory . add Factory ( Movies Worker Factory ( create Movies Interactor ())) ĊĊĠĠĠĠĠĠĠ Ġreturn ĠConfiguration . Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Worker Factory ( movies Worker Factory ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġcreate Movies Interactor (): ĠI Movies Interactor Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠMov ies Interactor ( network Module , Ġdatabase , Ġnotifications ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Notifications Interactor (): ĠNotifications Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġnotifications ĊĠĠĠ Ġ} Ċ } Ċ