From a4e62c41b52bf37ed0143ed5d71534c3d264e9de Mon Sep 17 00:00:00 2001 From: Santosh Pingle Date: Mon, 11 Nov 2024 15:06:58 +0530 Subject: [PATCH 1/4] cancel api to cancel the sync job. --- .../android/fhir/demo/PeriodicSyncFragment.kt | 26 ++ .../fhir/demo/PeriodicSyncViewModel.kt | 35 ++- .../google/android/fhir/demo/SyncFragment.kt | 31 ++- .../fhir/demo/SyncFragmentViewModel.kt | 38 ++- demo/src/main/res/layout/periodic_sync.xml | 38 +++ demo/src/main/res/layout/sync.xml | 18 ++ .../android/fhir/sync/SyncInstrumentedTest.kt | 229 +++++++++++------- .../java/com/google/android/fhir/sync/Sync.kt | 119 +++++---- 8 files changed, 365 insertions(+), 169 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..74aee0db92 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 @@ -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