From be94dd532676a79cfa7723931a3f39d92722f0c8 Mon Sep 17 00:00:00 2001 From: santosh-pingle <86107848+santosh-pingle@users.noreply.github.com> Date: Wed, 29 Jan 2025 14:27:14 +0530 Subject: [PATCH] api support for sync job cancellation. (#2717) * cancel api to cancel the sync job. * remove commented code. * datastore to store uuid. * code cleanup. --------- Co-authored-by: Santosh Pingle --- .../android/fhir/demo/PeriodicSyncFragment.kt | 28 ++- .../fhir/demo/PeriodicSyncViewModel.kt | 45 ++-- .../google/android/fhir/demo/SyncFragment.kt | 29 ++- .../fhir/demo/SyncFragmentViewModel.kt | 12 +- demo/src/main/res/layout/periodic_sync.xml | 38 +++ demo/src/main/res/layout/sync.xml | 18 ++ .../android/fhir/sync/SyncInstrumentedTest.kt | 231 +++++++++++------- .../google/android/fhir/sync/FhirDataStore.kt | 39 ++- .../java/com/google/android/fhir/sync/Sync.kt | 187 ++++++++------ 9 files changed, 441 insertions(+), 186 deletions(-) diff --git a/demo/src/main/java/com/google/android/fhir/demo/PeriodicSyncFragment.kt b/demo/src/main/java/com/google/android/fhir/demo/PeriodicSyncFragment.kt index 4fc6d3c830..912ebbf517 100644 --- a/demo/src/main/java/com/google/android/fhir/demo/PeriodicSyncFragment.kt +++ b/demo/src/main/java/com/google/android/fhir/demo/PeriodicSyncFragment.kt @@ -1,5 +1,5 @@ /* - * Copyright 2024 Google LLC + * Copyright 2024-2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import android.view.LayoutInflater import android.view.MenuItem import android.view.View import android.view.ViewGroup +import android.widget.Button import android.widget.ProgressBar import android.widget.TextView import androidx.appcompat.app.AppCompatActivity @@ -48,6 +49,7 @@ class PeriodicSyncFragment : Fragment() { setUpActionBar() setHasOptionsMenu(true) refreshPeriodicSynUi() + setUpSyncButtons(view) } override fun onOptionsItemSelected(item: MenuItem): Boolean { @@ -67,6 +69,30 @@ class PeriodicSyncFragment : Fragment() { } } + private fun setUpSyncButtons(view: View) { + val syncNowButton = view.findViewById