ComboPlugin singletion.
This commit is contained in:
parent
41ebabe5e7
commit
357c84e2e2
|
@ -48,8 +48,7 @@ import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPe
|
|||
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfileFragment;
|
||||
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
||||
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfilePlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ComboFragment;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRFragment;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ComboPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||
|
@ -129,7 +128,7 @@ public class MainApp extends Application {
|
|||
if (Config.DANAR) pluginsList.add(DanaRKoreanPlugin.getPlugin());
|
||||
if (Config.DANAR) pluginsList.add(DanaRv2Plugin.getPlugin());
|
||||
if (Config.DANAR) pluginsList.add(DanaRSPlugin.getPlugin());
|
||||
if (Config.COMBO) pluginsList.add(ComboFragment.getPlugin());
|
||||
if (Config.COMBO) pluginsList.add(ComboPlugin.getPlugin());
|
||||
pluginsList.add(CareportalFragment.getPlugin());
|
||||
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
|
||||
if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getInstance());
|
||||
|
|
|
@ -27,12 +27,6 @@ import info.nightscout.androidaps.plugins.PumpCombo.events.EventComboPumpUpdateG
|
|||
public class ComboFragment extends Fragment implements View.OnClickListener {
|
||||
private static Logger log = LoggerFactory.getLogger(ComboFragment.class);
|
||||
|
||||
private static ComboPlugin comboPlugin = new ComboPlugin();
|
||||
|
||||
public static ComboPlugin getPlugin() {
|
||||
return comboPlugin;
|
||||
}
|
||||
|
||||
private Button refresh;
|
||||
|
||||
private TextView statusText;
|
||||
|
@ -103,7 +97,7 @@ public class ComboFragment extends Fragment implements View.OnClickListener {
|
|||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getPlugin().refreshDataFromPump("User request");
|
||||
ComboPlugin.getPlugin().refreshDataFromPump("User request");
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
|
@ -117,9 +111,10 @@ public class ComboFragment extends Fragment implements View.OnClickListener {
|
|||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
statusText.setText(getPlugin().getPump().stateSummary);
|
||||
if (getPlugin().isInitialized()) {
|
||||
PumpState ps = getPlugin().getPump().state;
|
||||
ComboPlugin plugin = ComboPlugin.getPlugin();
|
||||
statusText.setText(plugin.getPump().stateSummary);
|
||||
if (plugin.isInitialized()) {
|
||||
PumpState ps = plugin.getPump().state;
|
||||
if (ps != null) {
|
||||
boolean tbrActive = ps.tbrPercent != -1 && ps.tbrPercent != 100;
|
||||
if (tbrActive) {
|
||||
|
@ -152,16 +147,16 @@ public class ComboFragment extends Fragment implements View.OnClickListener {
|
|||
}
|
||||
}
|
||||
|
||||
Command lastCmd = getPlugin().getPump().lastCmd;
|
||||
Command lastCmd = plugin.getPump().lastCmd;
|
||||
if (lastCmd != null) {
|
||||
lastCmdText.setText(lastCmd.toString());
|
||||
lastCmdTimeText.setText(getPlugin().getPump().lastCmdTime.toLocaleString());
|
||||
lastCmdTimeText.setText(plugin.getPump().lastCmdTime.toLocaleString());
|
||||
} else {
|
||||
lastCmdText.setText("");
|
||||
lastCmdTimeText.setText("");
|
||||
}
|
||||
|
||||
CommandResult lastCmdResult = getPlugin().getPump().lastCmdResult;
|
||||
CommandResult lastCmdResult = plugin.getPump().lastCmdResult;
|
||||
if (lastCmdResult != null && lastCmdResult.message != null) {
|
||||
lastCmdResultText.setText(lastCmdResult.message);
|
||||
lastCmdDurationText.setText(lastCmdResult.duration);
|
||||
|
|
|
@ -62,7 +62,13 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
|
||||
private ComboPump pump = new ComboPump();
|
||||
|
||||
private boolean ignoreLastSetTbrOrReadStateFailure = false;
|
||||
private static ComboPlugin plugin = null;
|
||||
|
||||
public static ComboPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new ComboPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private volatile BolusCommand runningBolusCommand;
|
||||
|
|
Loading…
Reference in a new issue