This commit is contained in:
Benoit Marty 2020-02-17 17:46:15 +01:00
parent 002e881704
commit 4995c14f69
1 changed files with 19 additions and 8 deletions

View File

@ -233,10 +233,11 @@ internal class DefaultSendService @AssistedInject constructor(
val dispatcherWork = createMultipleEventDispatcherWork(true)
val operation = workManagerProvider.workManager
workManagerProvider.workManager
.beginUniqueWork(buildWorkName(UPLOAD_WORK), ExistingWorkPolicy.APPEND, uploadWork)
.then(dispatcherWork)
.enqueue()
.also { operation ->
operation.result.addListener(Runnable {
if (operation.result.isCancelled) {
Timber.e("CHAIN WAS CANCELLED")
@ -244,6 +245,7 @@ internal class DefaultSendService @AssistedInject constructor(
Timber.e("CHAIN DID FAIL")
}
}, workerFutureListenerExecutor)
}
cancelableBag.add(CancelableWork(workManagerProvider.workManager, dispatcherWork.id))
}
@ -256,6 +258,15 @@ internal class DefaultSendService @AssistedInject constructor(
.beginUniqueWork(buildWorkName(UPLOAD_WORK), ExistingWorkPolicy.APPEND, uploadWork)
.then(dispatcherWork)
.enqueue()
.also { operation ->
operation.result.addListener(Runnable {
if (operation.result.isCancelled) {
Timber.e("CHAIN WAS CANCELLED")
} else if (operation.state.value is Operation.State.FAILURE) {
Timber.e("CHAIN DID FAIL")
}
}, workerFutureListenerExecutor)
}
cancelableBag.add(CancelableWork(workManagerProvider.workManager, dispatcherWork.id))
}