Lint RestartWorker.clean

This commit is contained in:
sim 2023-02-25 13:47:49 +01:00
parent c9d4e2fd13
commit ef7d50cdbf

View File

@ -36,16 +36,16 @@ class RestartWorker(ctx: Context, params: WorkerParameters) : Worker(ctx, params
companion object { companion object {
fun start(context: Context, delay: Long? = null) { fun start(context: Context, delay: Long? = null) {
val work = PeriodicWorkRequestBuilder<RestartWorker>(16, TimeUnit.MINUTES) val work = PeriodicWorkRequestBuilder<RestartWorker>(16, TimeUnit.MINUTES)
if (delay != null) { delay?.let {
lastEventDate = null lastEventDate = null
work.setInitialDelay(delay, TimeUnit.SECONDS) work.setInitialDelay(it, TimeUnit.SECONDS)
} }
val workManager = WorkManager.getInstance(context) WorkManager.getInstance(context)
workManager.enqueueUniquePeriodicWork( .enqueueUniquePeriodicWork(
UNIQUE_WORK_TAG, UNIQUE_WORK_TAG,
ExistingPeriodicWorkPolicy.REPLACE, ExistingPeriodicWorkPolicy.REPLACE,
work.build() work.build()
) )
} }
} }
} }