-
public final class WorkManagerReplicationKt
-
-
Method Summary
Modifier and Type Method Description final static ReplicatorStatus
toReplicatorStatus(Data $self, String replId)
Convert a Data
object found inWorkflowInfo
, to aReplicatorStatus
Once aReplicatorWorker
has been scheduled, its progress can be tracked using theLiveData
object provide by theWorkManager
, like this:
That bit of code will produces aWorkManager.getInstance(context) .getWorkInfosByTagLiveData(InventoryReplicatorFactory().tag)
LiveData<List<WorkflowInfo>>
.-
-
Method Detail
-
toReplicatorStatus
final static ReplicatorStatus toReplicatorStatus(Data $self, String replId)
Convert a
Data
object found inWorkflowInfo
, to aReplicatorStatus
Once a
ReplicatorWorker
has been scheduled, its progress can be tracked using theLiveData
object provide by theWorkManager
, like this:WorkManager.getInstance(context) .getWorkInfosByTagLiveData(InventoryReplicatorFactory().tag)
That bit of code will produces a
LiveData<List<WorkflowInfo>>
. Again, presuming that client code uses the tag from theWorkManagerReplicatorFactory
, for this and no otherWorkManager
jobs, this code can be used to recover theReplicatorStatus
from theData
object in theWorkflowInfo
:.map { if (it.isEmpty()) { null } else { it[0].progress.toReplicatorStatus() } }
-
-
-
-