Callback -> kt

This commit is contained in:
Milos Kozak 2022-05-27 20:24:21 +02:00
parent 50a89a7890
commit 67ab3fc0df
3 changed files with 16 additions and 18 deletions

View file

@ -15,9 +15,10 @@ class CommandCustomCommand(
@Inject lateinit var activePlugin: ActivePlugin
override fun execute() {
val result = activePlugin.activePump.executeCustomCommand(customCommand)
aapsLogger.debug(LTag.PUMPQUEUE, "Result success: ${result?.success} enacted: ${result?.enacted}")
callback?.result(result)?.run()
activePlugin.activePump.executeCustomCommand(customCommand)?.let {
aapsLogger.debug(LTag.PUMPQUEUE, "Result success: ${it.success} enacted: ${it.enacted}")
callback?.result(it)?.run()
}
}
override fun status(): String = customCommand.statusDescription

View file

@ -1,15 +0,0 @@
package info.nightscout.androidaps.queue;
import info.nightscout.androidaps.data.PumpEnactResult;
/**
* Created by mike on 09.11.2017.
*/
public abstract class Callback implements Runnable {
public PumpEnactResult result;
public Callback result(PumpEnactResult result) {
this.result = result;
return this;
}
}

View file

@ -0,0 +1,12 @@
package info.nightscout.androidaps.queue
import info.nightscout.androidaps.data.PumpEnactResult
abstract class Callback : Runnable {
lateinit var result: PumpEnactResult
fun result(result: PumpEnactResult): Callback {
this.result = result
return this
}
}