package app.furmeet.events.brasilfurfest.notification

import android.app.job.JobParameters
import android.app.job.JobService
import app.furmeet.events.brasilfurfest.helper.resourcesAliased
import org.jetbrains.anko.doAsync
import java.util.concurrent.Future

class NotificationJobService : JobService() {
    lateinit var fut: Future<Unit>
    override fun onStartJob(jobParameters: JobParameters): Boolean {
        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
    }
}