EROS: do not run commands on UI thread

This commit is contained in:
Milos Kozak 2021-10-30 16:24:19 +02:00
parent 3a33529307
commit da45219b98
2 changed files with 6 additions and 2 deletions

View file

@ -3,6 +3,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.eros.ui
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.HandlerThread
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
@ -54,6 +56,7 @@ class ErosPodManagementActivity : NoSplashAppCompatActivity() {
@Inject lateinit var aapsSchedulers: AapsSchedulers
private var disposables: CompositeDisposable = CompositeDisposable()
private val loopHandler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
private lateinit var binding: OmnipodErosPodManagementBinding
@ -97,7 +100,7 @@ class ErosPodManagementActivity : NoSplashAppCompatActivity() {
binding.buttonResetRileylinkConfig.setOnClickListener {
// TODO improvement: properly disable button until task is finished
serviceTaskExecutor.startTask(ResetRileyLinkConfigurationTask(injector))
loopHandler.post { serviceTaskExecutor.startTask(ResetRileyLinkConfigurationTask(injector)) }
}
binding.buttonPlayTestBeep.setOnClickListener {

View file

@ -4,6 +4,7 @@ import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.os.Handler
import android.os.HandlerThread
import android.os.Looper
import android.text.TextUtils
import android.view.LayoutInflater
@ -86,7 +87,7 @@ class OmnipodErosOverviewFragment : DaggerFragment() {
private var disposables: CompositeDisposable = CompositeDisposable()
private val loopHandler = Handler(Looper.getMainLooper())
private val loopHandler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
private lateinit var refreshLoop: Runnable
init {