do not run RandomBgPlugin in main thread

This commit is contained in:
Milos Kozak 2020-07-03 00:24:01 +02:00
parent 9361010e46
commit 045b79d22f

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.source
import android.content.Intent
import android.os.Handler
import android.os.HandlerThread
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
@ -12,6 +13,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.androidaps.utils.DateUtil
@ -45,7 +47,7 @@ class RandomBgPlugin @Inject constructor(
aapsLogger, resourceHelper, injector
), BgSourceInterface {
private val loopHandler = Handler()
private val loopHandler : Handler = Handler(HandlerThread(RandomBgPlugin::class.java.simpleName + "Handler").also { it.start() }.looper)
private lateinit var refreshLoop: Runnable
companion object {