Merge branch 'github/main'

pull/836/head
Automerger 2 years ago
commit 3741965e4e

@ -27,7 +27,7 @@ androidxTestRunner = "1.5.1"
androidxTracing = "1.1.0"
androidxUiAutomator = "2.2.0"
androidxWindowManager = "1.0.0"
androidxWork = "2.7.1"
androidxWork = "2.9.0-alpha01"
coil = "2.2.2"
firebaseBom = "31.2.0"
firebaseCrashlyticsPlugin = "2.9.2"

@ -17,8 +17,6 @@
package com.google.samples.apps.nowinandroid.sync.status
import android.content.Context
import androidx.lifecycle.asFlow
import androidx.lifecycle.map
import androidx.work.ExistingWorkPolicy
import androidx.work.WorkInfo
import androidx.work.WorkInfo.State
@ -29,6 +27,7 @@ import com.google.samples.apps.nowinandroid.sync.workers.SyncWorker
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.flow.map
import javax.inject.Inject
/**
@ -38,9 +37,8 @@ class WorkManagerSyncManager @Inject constructor(
@ApplicationContext private val context: Context,
) : SyncManager {
override val isSyncing: Flow<Boolean> =
WorkManager.getInstance(context).getWorkInfosForUniqueWorkLiveData(SyncWorkName)
.map(MutableList<WorkInfo>::anyRunning)
.asFlow()
WorkManager.getInstance(context).getWorkInfosForUniqueWorkFlow(SyncWorkName)
.map(List<WorkInfo>::anyRunning)
.conflate()
override fun requestSync() {
@ -54,4 +52,4 @@ class WorkManagerSyncManager @Inject constructor(
}
}
private val List<WorkInfo>.anyRunning get() = any { it.state == State.RUNNING }
private fun List<WorkInfo>.anyRunning() = any { it.state == State.RUNNING }

Loading…
Cancel
Save