DanaR pumps lifecycle
This commit is contained in:
parent
a30334f5d5
commit
1c6c5f85f7
4 changed files with 54 additions and 16 deletions
|
@ -64,7 +64,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
||||||
@Override
|
@Override
|
||||||
public void onStateChange(PluginType type, State oldState, State newState) {
|
public void onStateChange(PluginType type, State oldState, State newState) {
|
||||||
// if pump profile was enabled need to switch to another too
|
// if pump profile was enabled need to switch to another too
|
||||||
if (type == PluginType.PUMP && newState == State.DISABLED && isProfileInterfaceEnabled) {
|
if (type == PluginType.PUMP && newState == State.ENABLED && newState == State.DISABLED && isProfileInterfaceEnabled) {
|
||||||
setPluginEnabled(PluginType.PROFILE, false);
|
setPluginEnabled(PluginType.PROFILE, false);
|
||||||
NSProfilePlugin.getPlugin().setPluginEnabled(PluginType.PROFILE, true);
|
NSProfilePlugin.getPlugin().setPluginEnabled(PluginType.PROFILE, true);
|
||||||
NSProfilePlugin.getPlugin().setFragmentVisible(PluginType.PROFILE, true);
|
NSProfilePlugin.getPlugin().setFragmentVisible(PluginType.PROFILE, true);
|
||||||
|
|
|
@ -46,11 +46,6 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
log = LoggerFactory.getLogger(DanaRPlugin.class);
|
log = LoggerFactory.getLogger(DanaRPlugin.class);
|
||||||
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
||||||
|
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
|
||||||
Intent intent = new Intent(context, DanaRExecutionService.class);
|
|
||||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
|
||||||
MainApp.bus().register(this);
|
|
||||||
|
|
||||||
pumpDescription.isBolusCapable = true;
|
pumpDescription.isBolusCapable = true;
|
||||||
pumpDescription.bolusStep = 0.05d;
|
pumpDescription.bolusStep = 0.05d;
|
||||||
|
|
||||||
|
@ -78,6 +73,22 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
pumpDescription.storesCarbInfo = true;
|
pumpDescription.storesCarbInfo = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
|
Intent intent = new Intent(context, DanaRExecutionService.class);
|
||||||
|
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
MainApp.bus().register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
|
context.unbindService(mConnection);
|
||||||
|
|
||||||
|
MainApp.bus().unregister(this);
|
||||||
|
}
|
||||||
|
|
||||||
private ServiceConnection mConnection = new ServiceConnection() {
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
|
|
@ -26,6 +26,8 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.services.DanaRKoreanExecutionService;
|
import info.nightscout.androidaps.plugins.PumpDanaRKorean.services.DanaRKoreanExecutionService;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceChange;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.services.DanaRSService;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
@ -47,11 +49,6 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
log = LoggerFactory.getLogger(DanaRKoreanPlugin.class);
|
log = LoggerFactory.getLogger(DanaRKoreanPlugin.class);
|
||||||
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
||||||
|
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
|
||||||
Intent intent = new Intent(context, DanaRKoreanExecutionService.class);
|
|
||||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
|
||||||
MainApp.bus().register(this);
|
|
||||||
|
|
||||||
pumpDescription.isBolusCapable = true;
|
pumpDescription.isBolusCapable = true;
|
||||||
pumpDescription.bolusStep = 0.1d;
|
pumpDescription.bolusStep = 0.1d;
|
||||||
|
|
||||||
|
@ -79,6 +76,22 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
pumpDescription.storesCarbInfo = true;
|
pumpDescription.storesCarbInfo = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
|
Intent intent = new Intent(context, DanaRKoreanExecutionService.class);
|
||||||
|
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
MainApp.bus().register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
|
context.unbindService(mConnection);
|
||||||
|
|
||||||
|
MainApp.bus().unregister(this);
|
||||||
|
}
|
||||||
|
|
||||||
private ServiceConnection mConnection = new ServiceConnection() {
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
|
|
@ -23,6 +23,8 @@ import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceChange;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRS.services.DanaRSService;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService;
|
import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
@ -44,11 +46,6 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
log = LoggerFactory.getLogger(DanaRv2Plugin.class);
|
log = LoggerFactory.getLogger(DanaRv2Plugin.class);
|
||||||
useExtendedBoluses = false;
|
useExtendedBoluses = false;
|
||||||
|
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
|
||||||
Intent intent = new Intent(context, DanaRv2ExecutionService.class);
|
|
||||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
|
||||||
MainApp.bus().register(this);
|
|
||||||
|
|
||||||
pumpDescription.isBolusCapable = true;
|
pumpDescription.isBolusCapable = true;
|
||||||
pumpDescription.bolusStep = 0.05d;
|
pumpDescription.bolusStep = 0.05d;
|
||||||
|
|
||||||
|
@ -78,6 +75,23 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
pumpDescription.storesCarbInfo = true;
|
pumpDescription.storesCarbInfo = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
|
Intent intent = new Intent(context, DanaRv2ExecutionService.class);
|
||||||
|
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
|
||||||
|
MainApp.bus().register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
|
context.unbindService(mConnection);
|
||||||
|
|
||||||
|
MainApp.bus().unregister(this);
|
||||||
|
}
|
||||||
|
|
||||||
private ServiceConnection mConnection = new ServiceConnection() {
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
|
Loading…
Reference in a new issue