mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2024-11-05 07:53:53 +00:00
update result checker in KronSchedulerWork
This commit is contained in:
parent
3845f6e0c5
commit
552ec14d66
@ -139,13 +139,14 @@ abstract class KronSchedulerWork(
|
||||
}
|
||||
throw e
|
||||
}
|
||||
result.outputData
|
||||
if (result.isSuccess()) {
|
||||
result.checkResults(
|
||||
onFailure = {
|
||||
if (prolongOnFailure) prolong()
|
||||
},
|
||||
onSuccess = {
|
||||
if (prolongOnSuccess) prolong()
|
||||
}
|
||||
if (result.isFailure()) {
|
||||
if (prolongOnFailure) prolong()
|
||||
}
|
||||
)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
@ -8,3 +8,14 @@ internal fun ListenableWorker.Result.isSuccess() = this is ListenableWorker.Resu
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
internal fun ListenableWorker.Result.isFailure() = this is ListenableWorker.Result.Failure
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
internal inline fun ListenableWorker.Result.checkResults(
|
||||
onFailure: () -> Unit,
|
||||
onSuccess: () -> Unit
|
||||
) {
|
||||
when (this) {
|
||||
is ListenableWorker.Result.Failure -> onFailure()
|
||||
is ListenableWorker.Result.Success -> onSuccess()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user