diff --git a/demo/src/main/java/com/google/android/fhir/demo/PeriodicSyncViewModel.kt b/demo/src/main/java/com/google/android/fhir/demo/PeriodicSyncViewModel.kt index efcb19b651..4099b79dd6 100644 --- a/demo/src/main/java/com/google/android/fhir/demo/PeriodicSyncViewModel.kt +++ b/demo/src/main/java/com/google/android/fhir/demo/PeriodicSyncViewModel.kt @@ -30,7 +30,6 @@ import com.google.android.fhir.sync.PeriodicSyncJobStatus import com.google.android.fhir.sync.RepeatInterval import com.google.android.fhir.sync.Sync import com.google.android.fhir.sync.SyncJobStatus -import java.util.* import java.util.concurrent.TimeUnit import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow diff --git a/demo/src/main/java/com/google/android/fhir/demo/SyncFragment.kt b/demo/src/main/java/com/google/android/fhir/demo/SyncFragment.kt index 53eac823c8..7e0ab120e7 100644 --- a/demo/src/main/java/com/google/android/fhir/demo/SyncFragment.kt +++ b/demo/src/main/java/com/google/android/fhir/demo/SyncFragment.kt @@ -55,7 +55,7 @@ class SyncFragment : Fragment() { } observeLastSyncTime() launchAndRepeatStarted( - { syncFragmentViewModel.pollState.collect(::updateSyncJobStatus) }, + { syncFragmentViewModel.pollState.collect(::collectSyncJobStatus) }, ) } @@ -76,7 +76,7 @@ class SyncFragment : Fragment() { } } - private fun updateSyncJobStatus(currentSyncJobStatus: CurrentSyncJobStatus) { + private fun collectSyncJobStatus(currentSyncJobStatus: CurrentSyncJobStatus) { Timber.d("currentSyncJobStatus: $currentSyncJobStatus") // Update status text val statusTextView = requireView().findViewById(R.id.current_status) diff --git a/demo/src/main/java/com/google/android/fhir/demo/SyncFragmentViewModel.kt b/demo/src/main/java/com/google/android/fhir/demo/SyncFragmentViewModel.kt index 021b57616c..d684e09ff3 100644 --- a/demo/src/main/java/com/google/android/fhir/demo/SyncFragmentViewModel.kt +++ b/demo/src/main/java/com/google/android/fhir/demo/SyncFragmentViewModel.kt @@ -27,7 +27,6 @@ import com.google.android.fhir.sync.CurrentSyncJobStatus import com.google.android.fhir.sync.Sync import java.time.OffsetDateTime import java.time.format.DateTimeFormatter -import java.util.* import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.flow.MutableSharedFlow @@ -41,7 +40,6 @@ import kotlinx.coroutines.launch /** View model for [MainActivity]. */ @OptIn(ExperimentalCoroutinesApi::class) class SyncFragmentViewModel(application: Application) : AndroidViewModel(application) { - private var oneTimeSyncUuid: UUID? = null private val _lastSyncTimestampLiveData = MutableLiveData() val lastSyncTimestampLiveData: LiveData get() = _lastSyncTimestampLiveData diff --git a/engine/src/main/java/com/google/android/fhir/sync/FhirDataStore.kt b/engine/src/main/java/com/google/android/fhir/sync/FhirDataStore.kt index bae890d42f..857d529540 100644 --- a/engine/src/main/java/com/google/android/fhir/sync/FhirDataStore.kt +++ b/engine/src/main/java/com/google/android/fhir/sync/FhirDataStore.kt @@ -23,7 +23,7 @@ import androidx.datastore.preferences.core.stringPreferencesKey import androidx.datastore.preferences.preferencesDataStore import java.io.IOException import java.time.OffsetDateTime -import java.util.* +import java.util.UUID import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.first @@ -101,12 +101,7 @@ internal class FhirDataStore(context: Context) { runBlocking { dataStore.edit { pref -> pref[lastSyncTimestampKey] = datetime.toString() } } } - /** - * Stores the given UUID in DataStore. - * - * @param uuid The UUID to store. - * @param workIdKey The key used to store the UUID. - */ + /** Stores the given UUID in DataStore. */ @PublishedApi internal suspend fun storeWorkId(uuid: UUID, workIdKey: String) { dataStore.edit { preferences -> @@ -114,12 +109,7 @@ internal class FhirDataStore(context: Context) { } } - /** - * Fetches the stored UUID from DataStore. - * - * @param workIdKey The key used to fetch the UUID. - * @return The stored UUID, or null if not found. - */ + /** Fetches the stored UUID from DataStore. */ @PublishedApi internal suspend fun fetchWorkId(workIdKey: String): UUID? { val preferences = dataStore.data.first() 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 357b7c1ecb..eb1028e81b 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 @@ -137,10 +137,6 @@ object Sync { } } - fun cancelWorkById(context: Context, workId: UUID) { - WorkManager.getInstance(context).cancelWorkById(workId) - } - /** * Retrieves the work information for a specific unique work name as a flow of pairs containing * the work state and the corresponding progress data if available. @@ -195,7 +191,6 @@ object Sync { createSyncStateForPeriodicSync( workerInfoSyncJobStatusPairFromWorkManager.first, workerInfoSyncJobStatusPairFromWorkManager.second, - syncJobStatusFromDataStore, ), ) } @@ -333,11 +328,7 @@ object Sync { private fun createSyncStateForPeriodicSync( workInfoState: WorkInfo.State, syncJobStatusFromWorkManager: SyncJobStatus?, - syncJobStatusFromDataStore: SyncJobStatus?, ): CurrentSyncJobStatus { - Timber.d( - "currentSyncJobStatus : $syncJobStatusFromWorkManager syncJobStatusFromDataStore: $syncJobStatusFromDataStore workInfoState: $workInfoState", - ) return when (workInfoState) { WorkInfo.State.ENQUEUED -> Enqueued WorkInfo.State.RUNNING -> {