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
|
throw e
|
||||||
}
|
}
|
||||||
result.outputData
|
result.checkResults(
|
||||||
if (result.isSuccess()) {
|
onFailure = {
|
||||||
if (prolongOnSuccess) prolong()
|
if (prolongOnFailure) prolong()
|
||||||
}
|
},
|
||||||
if (result.isFailure()) {
|
onSuccess = {
|
||||||
if (prolongOnFailure) prolong()
|
if (prolongOnSuccess) prolong()
|
||||||
}
|
}
|
||||||
|
)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,3 +8,14 @@ internal fun ListenableWorker.Result.isSuccess() = this is ListenableWorker.Resu
|
|||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
internal fun ListenableWorker.Result.isFailure() = this is ListenableWorker.Result.Failure
|
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