|
|
|
@ -17,8 +17,8 @@
|
|
|
|
|
package com.google.samples.apps.nowinandroid.sync.status
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import androidx.lifecycle.Transformations
|
|
|
|
|
import androidx.lifecycle.asFlow
|
|
|
|
|
import androidx.lifecycle.map
|
|
|
|
|
import androidx.work.WorkInfo
|
|
|
|
|
import androidx.work.WorkInfo.State
|
|
|
|
|
import androidx.work.WorkManager
|
|
|
|
@ -36,10 +36,8 @@ class WorkManagerSyncStatusMonitor @Inject constructor(
|
|
|
|
|
@ApplicationContext context: Context,
|
|
|
|
|
) : SyncStatusMonitor {
|
|
|
|
|
override val isSyncing: Flow<Boolean> =
|
|
|
|
|
Transformations.map(
|
|
|
|
|
WorkManager.getInstance(context).getWorkInfosForUniqueWorkLiveData(SyncWorkName),
|
|
|
|
|
MutableList<WorkInfo>::anyRunning,
|
|
|
|
|
)
|
|
|
|
|
WorkManager.getInstance(context).getWorkInfosForUniqueWorkLiveData(SyncWorkName)
|
|
|
|
|
.map(MutableList<WorkInfo>::anyRunning)
|
|
|
|
|
.asFlow()
|
|
|
|
|
.conflate()
|
|
|
|
|
}
|
|
|
|
|