move getConfigBuilder() to MainApp
This commit is contained in:
parent
2a2589f5eb
commit
58388c4a87
|
@ -47,10 +47,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private static ConfigBuilderFragment configBuilderFragment;
|
private static ConfigBuilderFragment configBuilderFragment;
|
||||||
|
|
||||||
public static ConfigBuilderFragment getConfigBuilder() {
|
|
||||||
return configBuilderFragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
|
@ -152,11 +152,11 @@ public class DataService extends IntentService {
|
||||||
String profile = bundles.getString("profile");
|
String profile = bundles.getString("profile");
|
||||||
NSProfile nsProfile = new NSProfile(new JSONObject(profile), activeProfile);
|
NSProfile nsProfile = new NSProfile(new JSONObject(profile), activeProfile);
|
||||||
EventNewBasalProfile event = new EventNewBasalProfile(nsProfile);
|
EventNewBasalProfile event = new EventNewBasalProfile(nsProfile);
|
||||||
if (MainActivity.getConfigBuilder() == null) {
|
if (MainApp.getConfigBuilder() == null) {
|
||||||
log.error("Config builder not ready on receive profile");
|
log.error("Config builder not ready on receive profile");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PumpInterface pump = MainActivity.getConfigBuilder().getActivePump();
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
if (pump != null) {
|
if (pump != null) {
|
||||||
pump.setNewBasalProfile(nsProfile);
|
pump.setNewBasalProfile(nsProfile);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class TempBasal {
|
||||||
|
|
||||||
public IobTotal iobCalc(Date time) {
|
public IobTotal iobCalc(Date time) {
|
||||||
IobTotal result = new IobTotal();
|
IobTotal result = new IobTotal();
|
||||||
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
|
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -208,7 +208,7 @@ public class LoopFragment extends Fragment implements View.OnClickListener, Plug
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventNewBG ev) {
|
public void onStatusEvent(final EventNewBG ev) {
|
||||||
ConstraintsInterface constraintsInterface = MainActivity.getConfigBuilder();
|
ConstraintsInterface constraintsInterface = MainApp.getConfigBuilder();
|
||||||
if (constraintsInterface.isAutomaticProcessingEnabled()) {
|
if (constraintsInterface.isAutomaticProcessingEnabled()) {
|
||||||
invoke();
|
invoke();
|
||||||
updateGUI();
|
updateGUI();
|
||||||
|
@ -216,8 +216,8 @@ public class LoopFragment extends Fragment implements View.OnClickListener, Plug
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invoke() {
|
private void invoke() {
|
||||||
ConstraintsInterface constraintsInterface = MainActivity.getConfigBuilder();
|
ConstraintsInterface constraintsInterface = MainApp.getConfigBuilder();
|
||||||
PumpInterface pumpInterface = MainActivity.getConfigBuilder().getActivePump();
|
PumpInterface pumpInterface = MainApp.getConfigBuilder().getActivePump();
|
||||||
APSResult result = null;
|
APSResult result = null;
|
||||||
|
|
||||||
if (constraintsInterface == null || pumpInterface == null || !isEnabled())
|
if (constraintsInterface == null || pumpInterface == null || !isEnabled())
|
||||||
|
|
|
@ -220,8 +220,8 @@ public class LowSuspendFragment extends Fragment implements View.OnClickListener
|
||||||
public void invoke() {
|
public void invoke() {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
DatabaseHelper.GlucoseStatus glucoseStatus = MainApp.getDbHelper().getGlucoseStatusData();
|
DatabaseHelper.GlucoseStatus glucoseStatus = MainApp.getDbHelper().getGlucoseStatusData();
|
||||||
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
PumpInterface pump = MainActivity.getConfigBuilder().getActivePump();
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
|
|
||||||
if (!isEnabled()) {
|
if (!isEnabled()) {
|
||||||
updateResultGUI(MainApp.instance().getString(R.string.openapsma_disabled));
|
updateResultGUI(MainApp.instance().getString(R.string.openapsma_disabled));
|
||||||
|
|
|
@ -216,8 +216,8 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseHelper.GlucoseStatus glucoseStatus = MainApp.getDbHelper().getGlucoseStatusData();
|
DatabaseHelper.GlucoseStatus glucoseStatus = MainApp.getDbHelper().getGlucoseStatusData();
|
||||||
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
PumpInterface pump = MainActivity.getConfigBuilder().getActivePump();
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
|
|
||||||
if (!isEnabled()) {
|
if (!isEnabled()) {
|
||||||
updateResultGUI(MainApp.instance().getString(R.string.openapsma_disabled));
|
updateResultGUI(MainApp.instance().getString(R.string.openapsma_disabled));
|
||||||
|
@ -266,8 +266,8 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener,
|
||||||
minBg = Round.roundTo(minBg, 1d);
|
minBg = Round.roundTo(minBg, 1d);
|
||||||
maxBg = Round.roundTo(maxBg, 1d);
|
maxBg = Round.roundTo(maxBg, 1d);
|
||||||
|
|
||||||
TreatmentsInterface treatments = MainActivity.getConfigBuilder().getActiveTreatments();
|
TreatmentsInterface treatments = MainApp.getConfigBuilder().getActiveTreatments();
|
||||||
TempBasalsInterface tempBasals = MainActivity.getConfigBuilder().getActiveTempBasals();
|
TempBasalsInterface tempBasals = MainApp.getConfigBuilder().getActiveTempBasals();
|
||||||
treatments.updateTotalIOB();
|
treatments.updateTotalIOB();
|
||||||
tempBasals.updateTotalIOB();
|
tempBasals.updateTotalIOB();
|
||||||
IobTotal bolusIob = treatments.getLastCalculation();
|
IobTotal bolusIob = treatments.getLastCalculation();
|
||||||
|
|
|
@ -12,6 +12,7 @@ import android.widget.EditText;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainActivity;
|
import info.nightscout.androidaps.MainActivity;
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Result;
|
import info.nightscout.androidaps.data.Result;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
@ -58,7 +59,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
|
||||||
|
|
||||||
String confirmMessage = getString(R.string.setextendedbolusquestion);
|
String confirmMessage = getString(R.string.setextendedbolusquestion);
|
||||||
|
|
||||||
Double insulinAfterConstraint = MainActivity.getConfigBuilder().applyBolusConstraints(insulin);
|
Double insulinAfterConstraint = MainApp.getConfigBuilder().applyBolusConstraints(insulin);
|
||||||
confirmMessage += " " + insulinAfterConstraint + " U ";
|
confirmMessage += " " + insulinAfterConstraint + " U ";
|
||||||
confirmMessage += getString(R.string.duration) + " " + durationInMinutes + "min ?";
|
confirmMessage += getString(R.string.duration) + " " + durationInMinutes + "min ?";
|
||||||
if (insulinAfterConstraint != insulin)
|
if (insulinAfterConstraint != insulin)
|
||||||
|
@ -73,7 +74,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
|
||||||
builder.setMessage(confirmMessage);
|
builder.setMessage(confirmMessage);
|
||||||
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
PumpInterface pump = MainActivity.getConfigBuilder().getActivePump();
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
Result result = pump.setExtendedBolus(finalInsulin, finalDurationInMinutes);
|
Result result = pump.setExtendedBolus(finalInsulin, finalDurationInMinutes);
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
|
|
|
@ -12,6 +12,7 @@ import android.widget.EditText;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainActivity;
|
import info.nightscout.androidaps.MainActivity;
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Result;
|
import info.nightscout.androidaps.data.Result;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
@ -63,13 +64,13 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
||||||
|
|
||||||
String confirmMessage = getString(R.string.setbasalquestion);
|
String confirmMessage = getString(R.string.setbasalquestion);
|
||||||
if (setAsPercent) {
|
if (setAsPercent) {
|
||||||
basalPercent = MainActivity.getConfigBuilder().applyBasalConstraints(basal.intValue());
|
basalPercent = MainApp.getConfigBuilder().applyBasalConstraints(basal.intValue());
|
||||||
confirmMessage += "\n " + basalPercent + "% ";
|
confirmMessage += "\n " + basalPercent + "% ";
|
||||||
confirmMessage += getString(R.string.duration) + " " + durationInMinutes + "min ?";
|
confirmMessage += getString(R.string.duration) + " " + durationInMinutes + "min ?";
|
||||||
if (basalPercent != basal.intValue())
|
if (basalPercent != basal.intValue())
|
||||||
confirmMessage += "\n" + getString(R.string.constraintapllied);
|
confirmMessage += "\n" + getString(R.string.constraintapllied);
|
||||||
} else {
|
} else {
|
||||||
Double basalAfterConstraint = MainActivity.getConfigBuilder().applyBasalConstraints(basal);
|
Double basalAfterConstraint = MainApp.getConfigBuilder().applyBasalConstraints(basal);
|
||||||
confirmMessage += "\n " + basalAfterConstraint + " U/h ";
|
confirmMessage += "\n " + basalAfterConstraint + " U/h ";
|
||||||
confirmMessage += getString(R.string.duration) + " " + durationInMinutes + "min ?";
|
confirmMessage += getString(R.string.duration) + " " + durationInMinutes + "min ?";
|
||||||
if (basalAfterConstraint != basal)
|
if (basalAfterConstraint != basal)
|
||||||
|
@ -86,7 +87,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
||||||
builder.setMessage(confirmMessage);
|
builder.setMessage(confirmMessage);
|
||||||
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
PumpInterface pump = MainActivity.getConfigBuilder().getActivePump();
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
Result result;
|
Result result;
|
||||||
if (setAsPercent) {
|
if (setAsPercent) {
|
||||||
result = pump.setTempBasalPercent(finalBasalPercent, finalDurationInMinutes);
|
result = pump.setTempBasalPercent(finalBasalPercent, finalDurationInMinutes);
|
||||||
|
|
|
@ -53,8 +53,8 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
||||||
|
|
||||||
String confirmMessage = getString(R.string.entertreatmentquestion);
|
String confirmMessage = getString(R.string.entertreatmentquestion);
|
||||||
|
|
||||||
Double insulinAfterConstraints = MainActivity.getConfigBuilder().applyBolusConstraints(insulin);
|
Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(insulin);
|
||||||
Integer carbsAfterConstraints = MainActivity.getConfigBuilder().applyCarbsConstraints(carbs);
|
Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(carbs);
|
||||||
|
|
||||||
confirmMessage += getString(R.string.bolus) + ": " + insulinAfterConstraints + "U";
|
confirmMessage += getString(R.string.bolus) + ": " + insulinAfterConstraints + "U";
|
||||||
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
||||||
|
@ -70,7 +70,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
||||||
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
||||||
PumpInterface pump = MainActivity.getConfigBuilder().getActivePump();
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
Result result = pump.deliverTreatment(finalInsulinAfterConstraints, finalCarbsAfterConstraints);
|
Result result = pump.deliverTreatment(finalInsulinAfterConstraints, finalCarbsAfterConstraints);
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
|
|
|
@ -115,8 +115,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
||||||
String confirmMessage = getString(R.string.entertreatmentquestion);
|
String confirmMessage = getString(R.string.entertreatmentquestion);
|
||||||
|
|
||||||
Double insulinAfterConstraints = MainActivity.getConfigBuilder().applyBolusConstraints(calculatedTotalInsulin);
|
Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(calculatedTotalInsulin);
|
||||||
Integer carbsAfterConstraints = MainActivity.getConfigBuilder().applyCarbsConstraints(calculatedCarbs);
|
Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(calculatedCarbs);
|
||||||
|
|
||||||
confirmMessage += "\n" + getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U";
|
confirmMessage += "\n" + getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U";
|
||||||
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
||||||
|
@ -139,7 +139,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
||||||
PumpInterface pump = MainActivity.getConfigBuilder().getActivePump();
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
Result result = pump.deliverTreatment(finalInsulinAfterConstraints, finalCarbsAfterConstraints);
|
Result result = pump.deliverTreatment(finalInsulinAfterConstraints, finalCarbsAfterConstraints);
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
|
@ -161,7 +161,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initDialog() {
|
private void initDialog() {
|
||||||
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), "No profile loaded from NS yet");
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), "No profile loaded from NS yet");
|
||||||
|
@ -197,8 +197,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IOB calculation
|
// IOB calculation
|
||||||
TreatmentsInterface treatments = MainActivity.getConfigBuilder().getActiveTreatments();
|
TreatmentsInterface treatments = MainApp.getConfigBuilder().getActiveTreatments();
|
||||||
TempBasalsInterface tempBasals = MainActivity.getConfigBuilder().getActiveTempBasals();
|
TempBasalsInterface tempBasals = MainApp.getConfigBuilder().getActiveTempBasals();
|
||||||
treatments.updateTotalIOB();
|
treatments.updateTotalIOB();
|
||||||
tempBasals.updateTotalIOB();
|
tempBasals.updateTotalIOB();
|
||||||
IobTotal bolusIob = treatments.getLastCalculation();
|
IobTotal bolusIob = treatments.getLastCalculation();
|
||||||
|
@ -213,7 +213,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateInsulin() {
|
private void calculateInsulin() {
|
||||||
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
|
|
||||||
// Entered values
|
// Entered values
|
||||||
String i_bg = this.bgInput.getText().toString().replace("," , ".");
|
String i_bg = this.bgInput.getText().toString().replace("," , ".");
|
||||||
|
@ -226,12 +226,12 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
c_carbs = (Integer) Math.round(c_carbs);
|
c_carbs = (Integer) Math.round(c_carbs);
|
||||||
Double c_correction = 0d;
|
Double c_correction = 0d;
|
||||||
try { c_correction = Double.parseDouble(i_correction.equals("") ? "0" : i_correction); } catch (Exception e) {}
|
try { c_correction = Double.parseDouble(i_correction.equals("") ? "0" : i_correction); } catch (Exception e) {}
|
||||||
if(c_correction != MainActivity.getConfigBuilder().applyBolusConstraints(c_correction)) {
|
if(c_correction != MainApp.getConfigBuilder().applyBolusConstraints(c_correction)) {
|
||||||
this.correctionInput.setText("");
|
this.correctionInput.setText("");
|
||||||
wizardDialogDeliverButton.setVisibility(Button.GONE);
|
wizardDialogDeliverButton.setVisibility(Button.GONE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(c_carbs != MainActivity.getConfigBuilder().applyCarbsConstraints(c_carbs)) {
|
if(c_carbs != MainApp.getConfigBuilder().applyCarbsConstraints(c_carbs)) {
|
||||||
this.carbsInput.setText("");
|
this.carbsInput.setText("");
|
||||||
wizardDialogDeliverButton.setVisibility(Button.GONE);
|
wizardDialogDeliverButton.setVisibility(Button.GONE);
|
||||||
return;
|
return;
|
||||||
|
@ -259,8 +259,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener {
|
||||||
carbsInsulin.setText(numberFormat.format(insulinFromCarbs) + "U");
|
carbsInsulin.setText(numberFormat.format(insulinFromCarbs) + "U");
|
||||||
|
|
||||||
// Insulin from IOB
|
// Insulin from IOB
|
||||||
TreatmentsInterface treatments = MainActivity.getConfigBuilder().getActiveTreatments();
|
TreatmentsInterface treatments = MainApp.getConfigBuilder().getActiveTreatments();
|
||||||
TempBasalsInterface tempBasals = MainActivity.getConfigBuilder().getActiveTempBasals();
|
TempBasalsInterface tempBasals = MainApp.getConfigBuilder().getActiveTempBasals();
|
||||||
treatments.updateTotalIOB();
|
treatments.updateTotalIOB();
|
||||||
tempBasals.updateTotalIOB();
|
tempBasals.updateTotalIOB();
|
||||||
IobTotal bolusIob = treatments.getLastCalculation();
|
IobTotal bolusIob = treatments.getLastCalculation();
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class OverviewFragment extends Fragment implements PluginBase {
|
||||||
cancelTempButton.setOnClickListener(new View.OnClickListener() {
|
cancelTempButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
PumpInterface pump = MainActivity.getConfigBuilder().getActivePump();
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
if (pump.isTempBasalInProgress()) {
|
if (pump.isTempBasalInProgress()) {
|
||||||
pump.cancelTempBasal();
|
pump.cancelTempBasal();
|
||||||
MainApp.bus().post(new EventTempBasalChange());
|
MainApp.bus().post(new EventTempBasalChange());
|
||||||
|
@ -271,9 +271,9 @@ public class OverviewFragment extends Fragment implements PluginBase {
|
||||||
public void updateGUI() {
|
public void updateGUI() {
|
||||||
BgReading actualBG = MainApp.getDbHelper().actualBg();
|
BgReading actualBG = MainApp.getDbHelper().actualBg();
|
||||||
BgReading lastBG = MainApp.getDbHelper().lastBg();
|
BgReading lastBG = MainApp.getDbHelper().lastBg();
|
||||||
if (MainActivity.getConfigBuilder() == null || MainActivity.getConfigBuilder().getActiveProfile() == null) // app not initialized yet
|
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null) // app not initialized yet
|
||||||
return;
|
return;
|
||||||
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ public class OverviewFragment extends Fragment implements PluginBase {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// **** Temp button ****
|
// **** Temp button ****
|
||||||
PumpInterface pump = MainActivity.getConfigBuilder().getActivePump();
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
|
|
||||||
if (pump.isTempBasalInProgress()) {
|
if (pump.isTempBasalInProgress()) {
|
||||||
TempBasal activeTemp = pump.getTempBasal();
|
TempBasal activeTemp = pump.getTempBasal();
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class SafetyFragment extends Fragment implements PluginBase, ConstraintsI
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
Double maxBasal = Double.parseDouble(SP.getString("openapsma_max_basal", "1").replace(",", "."));
|
Double maxBasal = Double.parseDouble(SP.getString("openapsma_max_basal", "1").replace(",", "."));
|
||||||
|
|
||||||
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (absoluteRate < 0) absoluteRate = 0d;
|
if (absoluteRate < 0) absoluteRate = 0d;
|
||||||
|
|
||||||
Integer maxBasalMult = 4;
|
Integer maxBasalMult = 4;
|
||||||
|
@ -115,7 +115,7 @@ public class SafetyFragment extends Fragment implements PluginBase, ConstraintsI
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
Double maxBasal = Double.parseDouble(SP.getString("openapsma_max_basal", "1").replace(",", "."));
|
Double maxBasal = Double.parseDouble(SP.getString("openapsma_max_basal", "1").replace(",", "."));
|
||||||
|
|
||||||
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
Double currentBasal = profile.getBasal(profile.secondsFromMidnight());
|
Double currentBasal = profile.getBasal(profile.secondsFromMidnight());
|
||||||
|
|
||||||
Double absoluteRate = currentBasal * ((double) percentRate / 100);
|
Double absoluteRate = currentBasal * ((double) percentRate / 100);
|
||||||
|
|
|
@ -134,9 +134,9 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
||||||
public void updateTotalIOB() {
|
public void updateTotalIOB() {
|
||||||
IobTotal total = new IobTotal();
|
IobTotal total = new IobTotal();
|
||||||
|
|
||||||
if (MainActivity.getConfigBuilder() == null || MainActivity.getConfigBuilder().getActiveProfile() == null) // app not initialized yet
|
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null) // app not initialized yet
|
||||||
return;
|
return;
|
||||||
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
lastCalculation = total;
|
lastCalculation = total;
|
||||||
return;
|
return;
|
||||||
|
@ -170,7 +170,7 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
||||||
@Override
|
@Override
|
||||||
public MealData getMealData() {
|
public MealData getMealData() {
|
||||||
MealData result = new MealData();
|
MealData result = new MealData();
|
||||||
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -207,9 +207,9 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(TreatmentsViewHolder holder, int position) {
|
public void onBindViewHolder(TreatmentsViewHolder holder, int position) {
|
||||||
if (MainActivity.getConfigBuilder() == null || MainActivity.getConfigBuilder().getActiveProfile() == null) // app not initialized yet
|
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null) // app not initialized yet
|
||||||
return;
|
return;
|
||||||
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return;
|
return;
|
||||||
// TODO: implement locales
|
// TODO: implement locales
|
||||||
|
|
|
@ -180,12 +180,12 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, PumpInt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNewBasalProfile(NSProfile profile) {
|
public void setNewBasalProfile(NSProfile profile) {
|
||||||
// Do nothing here. we are using MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
// Do nothing here. we are using MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseBasalRate() {
|
public double getBaseBasalRate() {
|
||||||
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return defaultBasalValue;
|
return defaultBasalValue;
|
||||||
return profile.getBasal(profile.secondsFromMidnight());
|
return profile.getBasal(profile.secondsFromMidnight());
|
||||||
|
@ -198,7 +198,7 @@ public class VirtualPumpFragment extends Fragment implements PluginBase, PumpInt
|
||||||
if (tempBasal.isAbsolute) {
|
if (tempBasal.isAbsolute) {
|
||||||
return tempBasal.absolute;
|
return tempBasal.absolute;
|
||||||
} else {
|
} else {
|
||||||
NSProfile profile = MainActivity.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return defaultBasalValue;
|
return defaultBasalValue;
|
||||||
Double baseRate = profile.getBasal(profile.secondsFromMidnight());
|
Double baseRate = profile.getBasal(profile.secondsFromMidnight());
|
||||||
|
|
Loading…
Reference in a new issue