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