Skip to content

Commit

Permalink
add Blocked state. (#2607)
Browse files Browse the repository at this point in the history
Co-authored-by: Santosh Pingle <[email protected]>
  • Loading branch information
santosh-pingle and Santosh Pingle authored Jul 9, 2024
1 parent 2e06cb2 commit 7a26aba
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down Expand Up @@ -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)
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion engine/src/main/java/com/google/android/fhir/sync/Sync.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -309,7 +310,7 @@ object Sync {
}
?: error("Inconsistent terminal syncJobStatus.")
CANCELLED -> Cancelled
else -> error("Inconsistent WorkInfo.State: $workInfoState.")
BLOCKED -> CurrentSyncJobStatus.Blocked
}

/**
Expand All @@ -328,6 +329,7 @@ object Sync {
?: Enqueued
}
CANCELLED -> Cancelled
BLOCKED -> CurrentSyncJobStatus.Blocked
else -> error("Inconsistent WorkInfo.State in periodic sync : $workInfoState.")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

/**
Expand Down

0 comments on commit 7a26aba

Please sign in to comment.