From fced93c62fb43e136c365440c7a562c009f7371a Mon Sep 17 00:00:00 2001 From: Callum Stott Date: Wed, 4 Dec 2024 16:04:07 +0000 Subject: [PATCH] Clean up delegate helper signatures --- .../java/org/odk/collect/androidshared/data/Data.kt | 10 +++++----- .../collect/android/formmanagement/FormsDataService.kt | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/androidshared/src/main/java/org/odk/collect/androidshared/data/Data.kt b/androidshared/src/main/java/org/odk/collect/androidshared/data/Data.kt index 44a6020cd96..bb966ace614 100644 --- a/androidshared/src/main/java/org/odk/collect/androidshared/data/Data.kt +++ b/androidshared/src/main/java/org/odk/collect/androidshared/data/Data.kt @@ -32,6 +32,11 @@ abstract class DataService(private val appState: AppState, private val onUpdate: onUpdate?.invoke() } + protected fun data(key: String, default: T): DataDelegate { + val data = Data(appState, key, default) + return DataDelegate(data) + } + protected fun data(key: String, default: T, updater: () -> T): DataDelegate { val data = attachData(key, default) { updater() } return DataDelegate(data) @@ -42,11 +47,6 @@ abstract class DataService(private val appState: AppState, private val onUpdate: return DataDelegate(data) } - protected fun qualifiedData(key: String, default: T): DataDelegate { - val data = Data(appState, key, default) - return DataDelegate(data) - } - private fun attachData(key: String, default: T, updater: (String?) -> T): Data { val data = Data(appState, key, default) dataUpdaters.add(DataUpdater(data, updater)) diff --git a/collect_app/src/main/java/org/odk/collect/android/formmanagement/FormsDataService.kt b/collect_app/src/main/java/org/odk/collect/android/formmanagement/FormsDataService.kt index d4d1a36c7f1..5de4a068543 100644 --- a/collect_app/src/main/java/org/odk/collect/android/formmanagement/FormsDataService.kt +++ b/collect_app/src/main/java/org/odk/collect/android/formmanagement/FormsDataService.kt @@ -32,9 +32,9 @@ class FormsDataService( projectDependencies.formsRepository.all } - private val syncing by qualifiedData(DataKeys.SYNC_STATUS_SYNCING, false) - private val serverError by qualifiedData(DataKeys.SYNC_STATUS_ERROR, null) - private val diskError by qualifiedData(DataKeys.DISK_ERROR, null) + private val syncing by data(DataKeys.SYNC_STATUS_SYNCING, false) + private val serverError by data(DataKeys.SYNC_STATUS_ERROR, null) + private val diskError by data(DataKeys.DISK_ERROR, null) fun getForms(projectId: String): Flow> { return forms.get(projectId)