From 6711276732d6ef18ca0b27e7a8e258040dfde780 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 5 Apr 2022 17:49:25 +0200 Subject: [PATCH] let initialize plugins before accessing db --- .../info/nightscout/androidaps/MainApp.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.kt b/app/src/main/java/info/nightscout/androidaps/MainApp.kt index 1c2adea915..3bc938d2f8 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.kt @@ -95,18 +95,6 @@ class MainApp : DaggerApplication() { gitRemote = null commitHash = null } - disposable += repository.runTransaction(VersionChangeTransaction(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, gitRemote, commitHash)).subscribe() - if (sp.getBoolean(R.string.key_ns_logappstartedevent, config.APS)) - disposable += repository - .runTransaction( - InsertIfNewByTimestampTherapyEventTransaction( - timestamp = dateUtil.now(), - type = TherapyEvent.Type.NOTE, - note = getString(info.nightscout.androidaps.core.R.string.androidaps_start) + " - " + Build.MANUFACTURER + " " + Build.MODEL, - glucoseUnit = TherapyEvent.GlucoseUnit.MGDL - ) - ) - .subscribe() disposable += compatDBHelper.dbChangeDisposable() registerActivityLifecycleCallbacks(activityMonitor) JodaTimeAndroid.init(this) @@ -126,6 +114,18 @@ class MainApp : DaggerApplication() { pluginStore.plugins = plugins configBuilder.initialize() + disposable += repository.runTransaction(VersionChangeTransaction(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, gitRemote, commitHash)).subscribe() + if (sp.getBoolean(R.string.key_ns_logappstartedevent, config.APS)) + disposable += repository + .runTransaction( + InsertIfNewByTimestampTherapyEventTransaction( + timestamp = dateUtil.now(), + type = TherapyEvent.Type.NOTE, + note = getString(info.nightscout.androidaps.core.R.string.androidaps_start) + " - " + Build.MANUFACTURER + " " + Build.MODEL, + glucoseUnit = TherapyEvent.GlucoseUnit.MGDL + ) + ) + .subscribe() WorkManager.getInstance(this).enqueueUniquePeriodicWork( "KeepAlive", ExistingPeriodicWorkPolicy.REPLACE,