diff --git a/demo/src/main/java/com/google/android/fhir/demo/PatientListFragment.kt b/demo/src/main/java/com/google/android/fhir/demo/PatientListFragment.kt index 080dba3579..de218bfd46 100644 --- a/demo/src/main/java/com/google/android/fhir/demo/PatientListFragment.kt +++ b/demo/src/main/java/com/google/android/fhir/demo/PatientListFragment.kt @@ -189,7 +189,14 @@ class PatientListFragment : Fragment() { patientListViewModel.searchPatientsByName(searchView.query.toString().trim()) fadeOutTopBanner(currentSyncJobStatus) } - CurrentSyncJobStatus.Cancelled -> TODO() + is CurrentSyncJobStatus.Cancelled -> { + Timber.i("Sync: Cancelled") + fadeOutTopBanner(currentSyncJobStatus) + } + is CurrentSyncJobStatus.Blocked -> { + Timber.i("Sync: Blocked") + fadeOutTopBanner(currentSyncJobStatus) + } } } @@ -220,7 +227,14 @@ class PatientListFragment : Fragment() { patientListViewModel.searchPatientsByName(searchView.query.toString().trim()) fadeOutTopBanner(periodicSyncJobStatus.currentSyncJobStatus) } - CurrentSyncJobStatus.Cancelled -> TODO() + is CurrentSyncJobStatus.Cancelled -> { + Timber.i("Sync: Cancelled") + fadeOutTopBanner(periodicSyncJobStatus.currentSyncJobStatus) + } + is CurrentSyncJobStatus.Blocked -> { + Timber.i("Sync: Blocked") + fadeOutTopBanner(periodicSyncJobStatus.currentSyncJobStatus) + } } } diff --git a/engine/src/main/java/com/google/android/fhir/sync/Sync.kt b/engine/src/main/java/com/google/android/fhir/sync/Sync.kt index 47cf9f0e1e..ed8520f7fe 100644 --- a/engine/src/main/java/com/google/android/fhir/sync/Sync.kt +++ b/engine/src/main/java/com/google/android/fhir/sync/Sync.kt @@ -24,6 +24,7 @@ import androidx.work.ExistingWorkPolicy import androidx.work.OneTimeWorkRequest import androidx.work.PeriodicWorkRequest import androidx.work.WorkInfo +import androidx.work.WorkInfo.State.BLOCKED import androidx.work.WorkInfo.State.CANCELLED import androidx.work.WorkInfo.State.ENQUEUED import androidx.work.WorkInfo.State.FAILED @@ -309,7 +310,7 @@ object Sync { } ?: error("Inconsistent terminal syncJobStatus.") CANCELLED -> Cancelled - else -> error("Inconsistent WorkInfo.State: $workInfoState.") + BLOCKED -> CurrentSyncJobStatus.Blocked } /** @@ -328,6 +329,7 @@ object Sync { ?: Enqueued } CANCELLED -> Cancelled + BLOCKED -> CurrentSyncJobStatus.Blocked else -> error("Inconsistent WorkInfo.State in periodic sync : $workInfoState.") } diff --git a/engine/src/main/java/com/google/android/fhir/sync/SyncJobStatus.kt b/engine/src/main/java/com/google/android/fhir/sync/SyncJobStatus.kt index c74644d0dc..b3b18efbba 100644 --- a/engine/src/main/java/com/google/android/fhir/sync/SyncJobStatus.kt +++ b/engine/src/main/java/com/google/android/fhir/sync/SyncJobStatus.kt @@ -87,6 +87,9 @@ sealed class CurrentSyncJobStatus { /** State indicating that the synchronization operation is canceled. */ object Cancelled : CurrentSyncJobStatus() + + /** State indicating that the synchronization operation is blocked. */ + data object Blocked : CurrentSyncJobStatus() } /**