run aps calculation in thread to decouple from ui

This commit is contained in:
osodebailar 2022-04-25 16:51:26 +02:00
parent c16bb9ac5e
commit e956da034b
2 changed files with 5 additions and 5 deletions

View file

@ -59,7 +59,7 @@ class OpenAPSAMAFragment : DaggerFragment() {
setColorSchemeColors(rh.gac(context, R.attr.colorPrimaryDark), rh.gac(context, R.attr.colorPrimary), rh.gac(context, R.attr.colorSecondary))
setOnRefreshListener {
binding.lastrun.text = rh.gs(info.nightscout.androidaps.R.string.executing)
openAPSAMAPlugin.invoke("OpenAPSAMA swiperefresh", false)
Thread { openAPSAMAPlugin.invoke("OpenAPSAMA swiperefresh", false) }.start()
}
}
@ -76,7 +76,7 @@ class OpenAPSAMAFragment : DaggerFragment() {
when (item.itemId) {
ID_MENU_RUN -> {
binding.lastrun.text = rh.gs(R.string.executing)
openAPSAMAPlugin.invoke("OpenAPSAMA menu", false)
Thread { openAPSAMAPlugin.invoke("OpenAPSAMA menu", false) }.start()
true
}

View file

@ -36,6 +36,7 @@ class OpenAPSSMBFragment : DaggerFragment() {
@Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var jsonFormatter: JSONFormatter
private lateinit var refreshDialog: Runnable
private val ID_MENU_RUN = 1
@ -58,10 +59,9 @@ class OpenAPSSMBFragment : DaggerFragment() {
setColorSchemeColors(rh.gac(context, R.attr.colorPrimaryDark), rh.gac(context, R.attr.colorPrimary), rh.gac(context, R.attr.colorSecondary))
setOnRefreshListener {
binding.lastrun.text = rh.gs(info.nightscout.androidaps.R.string.executing)
activePlugin.activeAPS.invoke("OpenAPSSMB swiperefresh", false)
Thread { activePlugin.activeAPS.invoke("OpenAPSSMB swiperefresh", false) }.start()
}
}
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
@ -75,7 +75,7 @@ class OpenAPSSMBFragment : DaggerFragment() {
when (item.itemId) {
ID_MENU_RUN -> {
binding.lastrun.text = rh.gs(R.string.executing)
activePlugin.activeAPS.invoke("OpenAPSSMB menu", false)
Thread { activePlugin.activeAPS.invoke("OpenAPSSMB menu", false) }.start()
true
}