package app.furmeet.events.system.notification

import android.app.job.JobParameters
import android.app.job.JobService
import app.furmeet.events.system.helper.resourcesAliased
import app.furmeet.events.system.schedule.managers.FullUpdateCheckerCancellable
import app.furmeet.events.system.schedule.managers.RemoteAssetsHolder

class ScheduleUpdaterJobService : JobService() {
    private lateinit var fucc: FullUpdateCheckerCancellable

    override fun onStartJob(jobParameters: JobParameters): Boolean {
        RemoteAssetsHolder.ensureIsBuilt(this)
        resourcesAliased = resources
        fucc = FullUpdateCheckerCancellable(baseContext)
        fucc.run {
            NotificationFirer().fire(baseContext)
            jobFinished(jobParameters, true)
        }
        return true
    }

    override fun onStopJob(jobParameters: JobParameters): Boolean {
        fucc.stop()
        jobFinished(jobParameters, true)
        return true
    }

}