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 {
fun start(context: Context, delay: Long? = null) {
val work = PeriodicWorkRequestBuilder<RestartWorker>(16, TimeUnit.MINUTES)
if (delay != null) {
delay?.let {
lastEventDate = null
work.setInitialDelay(delay, TimeUnit.SECONDS)
work.setInitialDelay(it, TimeUnit.SECONDS)
}
val workManager = WorkManager.getInstance(context)
workManager.enqueueUniquePeriodicWork(
UNIQUE_WORK_TAG,
ExistingPeriodicWorkPolicy.REPLACE,
work.build()
)
WorkManager.getInstance(context)
.enqueueUniquePeriodicWork(
UNIQUE_WORK_TAG,
ExistingPeriodicWorkPolicy.REPLACE,
work.build()
)
}
}
}