package app.furmeet.events.system.notification

import android.app.job.JobParameters
import android.app.job.JobService
import app.furmeet.events.system.helper.doAsync
import app.furmeet.events.system.helper.resourcesAliased
import app.furmeet.events.system.schedule.managers.RemoteAssetsHolder
//import org.jetbrains.anko.doAsync
import java.util.concurrent.Future

class NotificationJobService : JobService() {
    lateinit var fut: Future<*>
    override fun onStartJob(jobParameters: JobParameters): Boolean {
        RemoteAssetsHolder.ensureIsBuilt(this)
        resourcesAliased = resources
        fut = doAsync {
            NotificationFirer().fire(this@NotificationJobService)
            jobFinished(jobParameters, true)
        }
        return true
    }

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