diff --git a/app/src/main/java/dgca/verifier/app/android/DgcaApplication.kt b/app/src/main/java/dgca/verifier/app/android/DgcaApplication.kt index cc4a5824..ac066d99 100644 --- a/app/src/main/java/dgca/verifier/app/android/DgcaApplication.kt +++ b/app/src/main/java/dgca/verifier/app/android/DgcaApplication.kt @@ -51,18 +51,18 @@ class DgcaApplication : Application(), Configuration.Provider { } WorkManager.getInstance(this).apply { - schedulePeriodicWorker() - schedulePeriodicWorker() - schedulePeriodicWorker() - schedulePeriodicWorker() - schedulePeriodicWorker() + schedulePeriodicWorker(WORKER_CONFIGS) + schedulePeriodicWorker(WORKER_RULES) + schedulePeriodicWorker(WORKER_KEYS) + schedulePeriodicWorker(WORKER_COUNTRIES) + schedulePeriodicWorker(WORKER_VALUESETS) } Timber.i("DGCA version ${BuildConfig.VERSION_NAME} is starting") } - private inline fun WorkManager.schedulePeriodicWorker() = - this.enqueue( + private inline fun WorkManager.schedulePeriodicWorker(workerId: String) = + this.enqueueUniquePeriodicWork(workerId, ExistingPeriodicWorkPolicy.KEEP, PeriodicWorkRequestBuilder(1, TimeUnit.DAYS) .setConstraints( Constraints.Builder() @@ -71,4 +71,12 @@ class DgcaApplication : Application(), Configuration.Provider { ) .build() ) + + companion object { + const val WORKER_CONFIGS = "workerConfigs" + const val WORKER_RULES = "workerRules" + const val WORKER_KEYS = "workerKeys" + const val WORKER_COUNTRIES = "workerCountries" + const val WORKER_VALUESETS = "workerValueSets" + } } \ No newline at end of file