setDanaConnection if not exists

This commit is contained in:
Milos Kozak 2016-07-13 16:19:26 +02:00
parent b81cf8341b
commit 7fc939f179

View file

@ -172,10 +172,9 @@ public class DanaRFragment extends Fragment implements PluginBase, PumpInterface
mHandler.post(new Runnable() {
@Override
public void run() {
if (getDanaConnection() != null)
if (getDanaConnection() == null)
setDanaConnection(new DanaConnection(MainApp.bus()));
getDanaConnection().connectIfNotConnected("Connect request from GUI");
else
log.error("Connect req from GUI: getDanaConnection() is null");
}
}
);
@ -292,11 +291,11 @@ public class DanaRFragment extends Fragment implements PluginBase, PumpInterface
@Override
public void setNewBasalProfile(NSProfile profile) {
if (getDanaConnection() != null) {
if (getDanaConnection() == null)
setDanaConnection(new DanaConnection(MainApp.bus()));
getDanaConnection().connectIfNotConnected("setNewBasalProfile");
getDanaConnection().updateBasalsInPump(profile);
}
}
@Override
public double getBaseBasalRate() {
@ -670,13 +669,11 @@ public class DanaRFragment extends Fragment implements PluginBase, PumpInterface
if (!getDanaRPump().isExtendedInProgress) {
result.success = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
result.isTempCancel = true;
if (Config.logPumpActions)
log.debug("cancelExtendedBolus: OK");
return result;
} else {
result.success = false;
result.isTempCancel = true;
result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly);
log.error("cancelExtendedBolus: Failed to cancel extended bolus");
return result;