This commit is contained in:
Milos Kozak 2019-07-23 00:26:59 +02:00
parent 47ed0acec2
commit ae7332df2d
9 changed files with 16 additions and 17 deletions

View file

@ -66,7 +66,6 @@ object AutomationPlugin : PluginBase(PluginDescription()
val context = MainApp.instance().applicationContext
context.startService(Intent(context, LocationService::class.java))
MainApp.bus().register(this)
super.onStart()
loadFromSP()
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
@ -171,7 +170,7 @@ object AutomationPlugin : PluginBase(PluginDescription()
executionLog.add(sb.toString())
if (L.isEnabled(L.AUTOMATION))
log.debug("Executed: $sb")
MainApp.bus().post(EventAutomationUpdateGui())
RxBus.send(EventAutomationUpdateGui())
}
})
}

View file

@ -8,6 +8,7 @@ import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.queue.Callback;
@ -30,7 +31,7 @@ public class ActionLoopDisable extends Action {
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() {
@Override
public void run() {
MainApp.bus().post(new EventRefreshOverview("ActionLoopDisable"));
RxBus.INSTANCE.send(new EventRefreshOverview("ActionLoopDisable"));
if (callback != null)
callback.result(result).run();
}

View file

@ -8,6 +8,7 @@ import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.queue.Callback;
@ -27,7 +28,7 @@ public class ActionLoopEnable extends Action {
if (!LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)) {
LoopPlugin.getPlugin().setPluginEnabled(PluginType.LOOP, true);
ConfigBuilderPlugin.getPlugin().storeSettings("ActionLoopEnable");
MainApp.bus().post(new EventRefreshOverview("ActionLoopEnable"));
RxBus.INSTANCE.send(new EventRefreshOverview("ActionLoopEnable"));
if (callback != null)
callback.result(new PumpEnactResult().success(true).comment(R.string.ok)).run();
} else {

View file

@ -7,6 +7,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
import info.nightscout.androidaps.queue.Callback;
@ -28,7 +29,7 @@ public class ActionLoopResume extends Action {
LoopPlugin.getPlugin().suspendTo(0);
ConfigBuilderPlugin.getPlugin().storeSettings("ActionLoopResume");
NSUpload.uploadOpenAPSOffline(0);
MainApp.bus().post(new EventRefreshOverview("ActionLoopResume"));
RxBus.INSTANCE.send(new EventRefreshOverview("ActionLoopResume"));
if (callback != null)
callback.result(new PumpEnactResult().success(true).comment(R.string.ok)).run();
} else {

View file

@ -12,6 +12,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration;
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement;
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder;
@ -35,7 +36,7 @@ public class ActionLoopSuspend extends Action {
public void doAction(Callback callback) {
if (!LoopPlugin.getPlugin().isSuspended()) {
LoopPlugin.getPlugin().suspendLoop(minutes.getMinutes());
MainApp.bus().post(new EventRefreshOverview("ActionLoopSuspend"));
RxBus.INSTANCE.send(new EventRefreshOverview("ActionLoopSuspend"));
if (callback != null)
callback.result(new PumpEnactResult().success(true).comment(R.string.ok)).run();
} else {

View file

@ -11,6 +11,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.general.automation.elements.InputString;
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement;
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder;
@ -36,9 +37,9 @@ public class ActionNotification extends Action {
@Override
public void doAction(Callback callback) {
Notification notification = new Notification(Notification.USERMESSAGE, text.getValue(), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
RxBus.INSTANCE.send(new EventNewNotification(notification));
NSUpload.uploadError(text.getValue());
MainApp.bus().post(new EventRefreshOverview("ActionNotification"));
RxBus.INSTANCE.send(new EventRefreshOverview("ActionNotification"));
if (callback != null)
callback.result(new PumpEnactResult().success(true).comment(R.string.ok)).run();

View file

@ -16,7 +16,7 @@ class ChooseTriggerDialog : DialogFragment() {
private var checkedIndex = -1
private var mClickListener: OnClickListener? = null
private var clickListener: OnClickListener? = null
interface OnClickListener {
fun onClick(newTriggerObject: Trigger?)
@ -49,10 +49,7 @@ class ChooseTriggerDialog : DialogFragment() {
// OK button
ok.setOnClickListener {
dismiss()
if (mClickListener != null)
mClickListener!!.onClick(instantiateTrigger())
dismiss()
clickListener?.onClick(instantiateTrigger())
}
// Cancel button
@ -60,7 +57,7 @@ class ChooseTriggerDialog : DialogFragment() {
}
fun setOnClickListener(clickListener: OnClickListener) {
mClickListener = clickListener
this.clickListener = clickListener
}
override fun onSaveInstanceState(bundle: Bundle) {

View file

@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import androidx.fragment.app.DialogFragment
import androidx.recyclerview.widget.LinearLayoutManager
import info.nightscout.androidaps.R
@ -54,7 +53,7 @@ class EditEventDialog : DialogFragment() {
}
// setup action list view
fragmentManager?.let { actionListAdapter = ActionListAdapter(it, event.actions)}
fragmentManager?.let { actionListAdapter = ActionListAdapter(it, event.actions) }
automation_actionListView.layoutManager = LinearLayoutManager(context)
automation_actionListView.adapter = actionListAdapter

View file

@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import androidx.fragment.app.DialogFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.plugins.bus.RxBus