rename identical functions
This commit is contained in:
parent
72f3efc39a
commit
a0d31b2118
|
@ -115,10 +115,10 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
|||
if (danaRPlugin.isEnabled(PluginBase.PUMP) || danaRKoreanPlugin.isEnabled(PluginBase.PUMP)) {
|
||||
addPreferencesFromResource(R.xml.pref_danar);
|
||||
}
|
||||
if (danaRv2Plugin.isEnabled(PluginBase.PUMP)) {
|
||||
if (danaRv2Plugin != null && danaRv2Plugin.isEnabled(PluginBase.PUMP)) {
|
||||
addPreferencesFromResource(R.xml.pref_danarv2);
|
||||
}
|
||||
if (danaRPlugin.isEnabled(PluginBase.PROFILE) || danaRKoreanPlugin.isEnabled(PluginBase.PROFILE) || danaRv2Plugin.isEnabled(PluginBase.PROFILE)) {
|
||||
if (danaRPlugin.isEnabled(PluginBase.PROFILE) || danaRKoreanPlugin.isEnabled(PluginBase.PROFILE) || danaRv2Plugin != null && danaRv2Plugin.isEnabled(PluginBase.PROFILE)) {
|
||||
addPreferencesFromResource(R.xml.pref_danarprofile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ import info.nightscout.androidaps.data.IobTotal;
|
|||
* Created by mike on 14.06.2016.
|
||||
*/
|
||||
public interface TempBasalsInterface {
|
||||
void updateTotalIOB();
|
||||
IobTotal getLastCalculation();
|
||||
IobTotal getCalculationToTime(long time);
|
||||
void updateTotalIOBTempBasals();
|
||||
IobTotal getLastCalculationTempBasals();
|
||||
IobTotal getCalculationToTimeTempBasals(long time);
|
||||
|
||||
TempBasal getTempBasal (Date time);
|
||||
TempBasal getExtendedBolus (Date time);
|
||||
|
|
|
@ -11,9 +11,9 @@ import info.nightscout.androidaps.data.IobTotal;
|
|||
*/
|
||||
public interface TreatmentsInterface {
|
||||
|
||||
void updateTotalIOB();
|
||||
IobTotal getLastCalculation();
|
||||
IobTotal getCalculationToTime(long time);
|
||||
void updateTotalIOBTreatments();
|
||||
IobTotal getLastCalculationTreatments();
|
||||
IobTotal getCalculationToTimeTreatments(long time);
|
||||
MealData getMealData();
|
||||
List<Treatment> getTreatments();
|
||||
List<Treatment> getTreatments5MinBack(long time);
|
||||
|
|
|
@ -16,7 +16,6 @@ import java.util.Arrays;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
|
@ -339,8 +338,8 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
|||
} else {
|
||||
//log.debug(">>> Cache miss " + new Date(time).toLocaleString());
|
||||
}
|
||||
IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getCalculationToTime(time).round();
|
||||
IobTotal basalIob = ConfigBuilderPlugin.getActiveTempBasals().getCalculationToTime(time).round();
|
||||
IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getCalculationToTimeTreatments(time).round();
|
||||
IobTotal basalIob = ConfigBuilderPlugin.getActiveTempBasals().getCalculationToTimeTempBasals(time).round();
|
||||
/*
|
||||
if (basalIob.basaliob > 0) {
|
||||
log.debug(new Date(time).toLocaleString() + " basaliob: " + basalIob.basaliob );
|
||||
|
|
|
@ -189,10 +189,10 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
Date start = new Date();
|
||||
TreatmentsInterface treatments = MainApp.getConfigBuilder().getActiveTreatments();
|
||||
TempBasalsInterface tempBasals = MainApp.getConfigBuilder().getActiveTempBasals();
|
||||
treatments.updateTotalIOB();
|
||||
tempBasals.updateTotalIOB();
|
||||
IobTotal bolusIob = treatments.getLastCalculation();
|
||||
IobTotal basalIob = tempBasals.getLastCalculation();
|
||||
treatments.updateTotalIOBTreatments();
|
||||
tempBasals.updateTotalIOBTempBasals();
|
||||
IobTotal bolusIob = treatments.getLastCalculationTreatments();
|
||||
IobTotal basalIob = tempBasals.getLastCalculationTempBasals();
|
||||
|
||||
IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob).round();
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.json.JSONException;
|
|||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
|
@ -52,10 +51,8 @@ import info.nightscout.androidaps.interfaces.TempBasalsInterface;
|
|||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.utils.BolusWizard;
|
||||
|
@ -414,13 +411,13 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Co
|
|||
|
||||
// IOB calculation
|
||||
TreatmentsInterface treatments = ConfigBuilderPlugin.getActiveTreatments();
|
||||
treatments.updateTotalIOB();
|
||||
IobTotal bolusIob = treatments.getLastCalculation();
|
||||
treatments.updateTotalIOBTreatments();
|
||||
IobTotal bolusIob = treatments.getLastCalculationTreatments();
|
||||
TempBasalsInterface tempBasals = ConfigBuilderPlugin.getActiveTempBasals();
|
||||
IobTotal basalIob = new IobTotal(new Date().getTime());
|
||||
if (tempBasals != null) {
|
||||
tempBasals.updateTotalIOB();
|
||||
basalIob = tempBasals.getLastCalculation().round();
|
||||
tempBasals.updateTotalIOBTempBasals();
|
||||
basalIob = tempBasals.getLastCalculationTempBasals().round();
|
||||
}
|
||||
|
||||
bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U");
|
||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.Overview;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.DashPathEffect;
|
||||
import android.graphics.Paint;
|
||||
|
@ -16,23 +15,19 @@ import android.support.v4.content.ContextCompat;
|
|||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.crashlytics.android.answers.Answers;
|
||||
|
@ -63,11 +58,9 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.PreferencesActivity;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
|
@ -76,7 +69,6 @@ import info.nightscout.androidaps.db.BgReading;
|
|||
import info.nightscout.androidaps.db.TempBasal;
|
||||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.events.EventAppExit;
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
import info.nightscout.androidaps.events.EventNewBG;
|
||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||
|
@ -115,9 +107,6 @@ import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTarget
|
|||
import info.nightscout.utils.BolusWizard;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.ImportExportPrefs;
|
||||
import info.nightscout.utils.LogDialog;
|
||||
import info.nightscout.utils.PasswordProtection;
|
||||
import info.nightscout.utils.Round;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
@ -1009,12 +998,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
timeAgoView.setText(String.format(MainApp.sResources.getString(R.string.minago), agoMin));
|
||||
|
||||
// iob
|
||||
ConfigBuilderPlugin.getActiveTreatments().updateTotalIOB();
|
||||
IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculation().round();
|
||||
ConfigBuilderPlugin.getActiveTreatments().updateTotalIOBTreatments();
|
||||
IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculationTreatments().round();
|
||||
IobTotal basalIob = new IobTotal(new Date().getTime());
|
||||
if (ConfigBuilderPlugin.getActiveTempBasals() != null) {
|
||||
ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOB();
|
||||
basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculation().round();
|
||||
ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOBTempBasals();
|
||||
basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculationTempBasals().round();
|
||||
}
|
||||
|
||||
String iobtext = getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
||||
|
|
|
@ -144,12 +144,12 @@ public class PersistentNotificationPlugin implements PluginBase{
|
|||
}
|
||||
|
||||
//IOB
|
||||
ConfigBuilderPlugin.getActiveTreatments().updateTotalIOB();
|
||||
IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculation().round();
|
||||
ConfigBuilderPlugin.getActiveTreatments().updateTotalIOBTreatments();
|
||||
IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculationTreatments().round();
|
||||
IobTotal basalIob = new IobTotal(new Date().getTime());
|
||||
if (ConfigBuilderPlugin.getActiveTempBasals() != null) {
|
||||
ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOB();
|
||||
basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculation().round();
|
||||
ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOBTempBasals();
|
||||
basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculationTempBasals().round();
|
||||
}
|
||||
String line2 = ctx.getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
||||
+ ctx.getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
|
||||
|
|
|
@ -36,12 +36,12 @@ import info.nightscout.androidaps.interfaces.ProfileInterface;
|
|||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
||||
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.Round;
|
||||
|
|
|
@ -43,8 +43,6 @@ import info.nightscout.utils.SP;
|
|||
import info.nightscout.utils.SafeParse;
|
||||
import info.nightscout.utils.XdripCalibrations;
|
||||
|
||||
import static info.nightscout.androidaps.R.string.profile;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
|
@ -256,10 +254,10 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
if (glucoseStatus != null)
|
||||
reply += MainApp.sResources.getString(R.string.sms_delta) + " " + NSProfile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", ";
|
||||
|
||||
ConfigBuilderPlugin.getActiveTreatments().updateTotalIOB();
|
||||
IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculation().round();
|
||||
ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOB();
|
||||
IobTotal basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculation().round();
|
||||
ConfigBuilderPlugin.getActiveTreatments().updateTotalIOBTreatments();
|
||||
IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculationTreatments().round();
|
||||
ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOBTempBasals();
|
||||
IobTotal basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculationTempBasals().round();
|
||||
|
||||
reply += MainApp.sResources.getString(R.string.sms_iob) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
||||
+ MainApp.sResources.getString(R.string.sms_bolus) + " " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
|
||||
|
|
|
@ -176,16 +176,16 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface {
|
|||
public void updateTotalIOBIfNeeded() {
|
||||
if (lastCalculationTimestamp > new Date().getTime() - 60 * 1000)
|
||||
return;
|
||||
updateTotalIOB();
|
||||
updateTotalIOBTempBasals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IobTotal getLastCalculation() {
|
||||
public IobTotal getLastCalculationTempBasals() {
|
||||
return lastCalculation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IobTotal getCalculationToTime(long time) {
|
||||
public IobTotal getCalculationToTimeTempBasals(long time) {
|
||||
checkForExpired(tempBasals);
|
||||
checkForExpired(extendedBoluses);
|
||||
IobTotal total = new IobTotal(time);
|
||||
|
@ -208,8 +208,8 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateTotalIOB() {
|
||||
IobTotal total = getCalculationToTime(new Date().getTime());
|
||||
public void updateTotalIOBTempBasals() {
|
||||
IobTotal total = getCalculationToTimeTempBasals(new Date().getTime());
|
||||
|
||||
lastCalculationTimestamp = new Date().getTime();
|
||||
lastCalculation = total;
|
||||
|
|
|
@ -1,51 +1,23 @@
|
|||
package info.nightscout.androidaps.plugins.Treatments;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.crashlytics.android.answers.Answers;
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.androidaps.data.Iob;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsBolusFragment;
|
||||
|
||||
public class TreatmentsFragment extends Fragment implements View.OnClickListener {
|
||||
public class TreatmentsFragment extends Fragment {
|
||||
private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class);
|
||||
|
||||
private static TreatmentsPlugin treatmentsPlugin = new TreatmentsPlugin();
|
||||
|
@ -54,112 +26,53 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
|||
return treatmentsPlugin;
|
||||
}
|
||||
|
||||
RecyclerView recyclerView;
|
||||
LinearLayoutManager llm;
|
||||
|
||||
TextView iobTotal;
|
||||
TextView activityTotal;
|
||||
Button refreshFromNS;
|
||||
SectionsPagerAdapter sectionsPagerAdapter;
|
||||
ViewPager viewPager;
|
||||
|
||||
Context context;
|
||||
|
||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TreatmentsViewHolder> {
|
||||
Fragment bolusFragment;
|
||||
|
||||
List<Treatment> treatments;
|
||||
public class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||
|
||||
RecyclerViewAdapter(List<Treatment> treatments) {
|
||||
this.treatments = treatments;
|
||||
public SectionsPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreatmentsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_item, viewGroup, false);
|
||||
return new TreatmentsViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(TreatmentsViewHolder holder, int position) {
|
||||
if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet
|
||||
return;
|
||||
NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
|
||||
InsulinInterface insulinInterface = ConfigBuilderPlugin.getActiveInsulin();
|
||||
if (profile == null || insulinInterface == null)
|
||||
return;
|
||||
holder.date.setText(DateUtil.dateAndTimeString(treatments.get(position).created_at));
|
||||
holder.insulin.setText(DecimalFormatter.to2Decimal(treatments.get(position).insulin) + " U");
|
||||
holder.carbs.setText(DecimalFormatter.to0Decimal(treatments.get(position).carbs) + " g");
|
||||
Iob iob = insulinInterface.iobCalc(treatments.get(position), new Date().getTime(), profile.getDia());
|
||||
holder.iob.setText(DecimalFormatter.to2Decimal(iob.iobContrib) + " U");
|
||||
holder.activity.setText(DecimalFormatter.to3Decimal(iob.activityContrib) + " U");
|
||||
holder.mealOrCorrection.setText(treatments.get(position).mealBolus ? MainApp.sResources.getString(R.string.mealbolus) : MainApp.sResources.getString(R.string.correctionbous));
|
||||
if (iob.iobContrib != 0)
|
||||
holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.colorAffectingIOB));
|
||||
else
|
||||
holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.cardColorBackground));
|
||||
holder.remove.setTag(treatments.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return treatments.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView);
|
||||
}
|
||||
|
||||
public class TreatmentsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
CardView cv;
|
||||
TextView date;
|
||||
TextView insulin;
|
||||
TextView carbs;
|
||||
TextView iob;
|
||||
TextView activity;
|
||||
TextView mealOrCorrection;
|
||||
LinearLayout dateLinearLayout;
|
||||
TextView remove;
|
||||
|
||||
TreatmentsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
cv = (CardView) itemView.findViewById(R.id.treatments_cardview);
|
||||
date = (TextView) itemView.findViewById(R.id.treatments_date);
|
||||
insulin = (TextView) itemView.findViewById(R.id.treatments_insulin);
|
||||
carbs = (TextView) itemView.findViewById(R.id.treatments_carbs);
|
||||
iob = (TextView) itemView.findViewById(R.id.treatments_iob);
|
||||
activity = (TextView) itemView.findViewById(R.id.treatments_activity);
|
||||
mealOrCorrection = (TextView) itemView.findViewById(R.id.treatments_mealorcorrection);
|
||||
dateLinearLayout = (LinearLayout) itemView.findViewById(R.id.treatments_datelinearlayout);
|
||||
remove = (TextView) itemView.findViewById(R.id.treatments_remove);
|
||||
remove.setOnClickListener(this);
|
||||
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||
public Fragment getItem(int position) {
|
||||
// getItem is called to instantiate the fragment for the given page.
|
||||
switch (position){
|
||||
case 0:
|
||||
return bolusFragment;
|
||||
case 1:
|
||||
return new Fragment();
|
||||
/*
|
||||
case 2:
|
||||
return iobcobActiveFragmentObject;
|
||||
case 3:
|
||||
return basalvsTempBasalObject;
|
||||
*/
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final Treatment treatment = (Treatment) v.getTag();
|
||||
switch (v.getId()) {
|
||||
case R.id.treatments_remove:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
||||
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(treatment.created_at));
|
||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
final String _id = treatment._id;
|
||||
if (_id != null && !_id.equals("")) {
|
||||
MainApp.getConfigBuilder().removeCareportalEntryFromNS(_id);
|
||||
}
|
||||
MainApp.getDbHelper().delete(treatment);
|
||||
treatmentsPlugin.initializeData();
|
||||
updateGUI();
|
||||
Answers.getInstance().logCustom(new CustomEvent("RemoveTreatment"));
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
|
||||
builder.show();
|
||||
break;
|
||||
}
|
||||
@Override
|
||||
public int getCount() {
|
||||
// Show 1 total pages.
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
return getString(R.string.bolus);
|
||||
case 1:
|
||||
return "Empty";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,87 +81,13 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
|
|||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.treatments_fragment, container, false);
|
||||
|
||||
recyclerView = (RecyclerView) view.findViewById(R.id.treatments_recyclerview);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
llm = new LinearLayoutManager(view.getContext());
|
||||
recyclerView.setLayoutManager(llm);
|
||||
|
||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.treatments);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
iobTotal = (TextView) view.findViewById(R.id.treatments_iobtotal);
|
||||
activityTotal = (TextView) view.findViewById(R.id.treatments_iobactivitytotal);
|
||||
|
||||
refreshFromNS = (Button) view.findViewById(R.id.treatments_reshreshfromnightscout);
|
||||
refreshFromNS.setOnClickListener(this);
|
||||
bolusFragment = new TreatmentsBolusFragment();
|
||||
|
||||
sectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager());
|
||||
viewPager = (ViewPager) view.findViewById(R.id.treatments_pager);
|
||||
viewPager.setAdapter(sectionsPagerAdapter);
|
||||
context = getContext();
|
||||
|
||||
updateGUI();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.treatments_reshreshfromnightscout:
|
||||
boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false);
|
||||
if (nsUploadOnly) {
|
||||
ToastUtils.showToastInUiThread(getContext(), this.getContext().getString(R.string.ns_upload_only_enabled));
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
|
||||
builder.setTitle(this.getContext().getString(R.string.confirmation));
|
||||
builder.setMessage(this.getContext().getString(R.string.refreshtreatmentsfromnightscout));
|
||||
builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
MainApp.getDbHelper().resetTreatments();
|
||||
treatmentsPlugin.initializeData();
|
||||
updateGUI();
|
||||
Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
|
||||
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(this.getContext().getString(R.string.cancel), null);
|
||||
builder.show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventTreatmentChange ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
public void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
if (profile == null)
|
||||
return;
|
||||
if (activity != null && recyclerView != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.treatments), false);
|
||||
if (TreatmentsPlugin.lastCalculation != null)
|
||||
iobTotal.setText(DecimalFormatter.to2Decimal(TreatmentsPlugin.lastCalculation.iob) + " U");
|
||||
if (TreatmentsPlugin.lastCalculation != null)
|
||||
activityTotal.setText(DecimalFormatter.to3Decimal(TreatmentsPlugin.lastCalculation.activity) + " U");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -120,16 +120,16 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
public void updateTotalIOBIfNeeded() {
|
||||
if (lastCalculationTimestamp > new Date().getTime() - 60 * 1000)
|
||||
return;
|
||||
updateTotalIOB();
|
||||
updateTotalIOBTreatments();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IobTotal getLastCalculation() {
|
||||
public IobTotal getLastCalculationTreatments() {
|
||||
return lastCalculation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IobTotal getCalculationToTime(long time) {
|
||||
public IobTotal getCalculationToTimeTreatments(long time) {
|
||||
IobTotal total = new IobTotal(time);
|
||||
|
||||
if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet
|
||||
|
@ -154,8 +154,8 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateTotalIOB() {
|
||||
IobTotal total = getCalculationToTime(new Date().getTime());
|
||||
public void updateTotalIOBTreatments() {
|
||||
IobTotal total = getCalculationToTimeTreatments(new Date().getTime());
|
||||
|
||||
lastCalculationTimestamp = new Date().getTime();
|
||||
lastCalculation = total;
|
||||
|
@ -209,7 +209,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
@Subscribe
|
||||
public void onStatusEvent(final EventTreatmentChange ev) {
|
||||
initializeData();
|
||||
updateTotalIOB();
|
||||
updateTotalIOBTreatments();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,253 @@
|
|||
package info.nightscout.androidaps.plugins.Treatments.fragments;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.crashlytics.android.answers.Answers;
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.androidaps.data.Iob;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
public class TreatmentsBolusFragment extends Fragment implements View.OnClickListener {
|
||||
private static Logger log = LoggerFactory.getLogger(TreatmentsBolusFragment.class);
|
||||
|
||||
private static TreatmentsPlugin treatmentsPlugin = new TreatmentsPlugin();
|
||||
|
||||
public static TreatmentsPlugin getPlugin() {
|
||||
return treatmentsPlugin;
|
||||
}
|
||||
|
||||
RecyclerView recyclerView;
|
||||
LinearLayoutManager llm;
|
||||
|
||||
TextView iobTotal;
|
||||
TextView activityTotal;
|
||||
Button refreshFromNS;
|
||||
|
||||
Context context;
|
||||
|
||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TreatmentsViewHolder> {
|
||||
|
||||
List<Treatment> treatments;
|
||||
|
||||
RecyclerViewAdapter(List<Treatment> treatments) {
|
||||
this.treatments = treatments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreatmentsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_item, viewGroup, false);
|
||||
return new TreatmentsViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(TreatmentsViewHolder holder, int position) {
|
||||
if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet
|
||||
return;
|
||||
NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
|
||||
InsulinInterface insulinInterface = ConfigBuilderPlugin.getActiveInsulin();
|
||||
if (profile == null || insulinInterface == null)
|
||||
return;
|
||||
holder.date.setText(DateUtil.dateAndTimeString(treatments.get(position).created_at));
|
||||
holder.insulin.setText(DecimalFormatter.to2Decimal(treatments.get(position).insulin) + " U");
|
||||
holder.carbs.setText(DecimalFormatter.to0Decimal(treatments.get(position).carbs) + " g");
|
||||
Iob iob = insulinInterface.iobCalc(treatments.get(position), new Date().getTime(), profile.getDia());
|
||||
holder.iob.setText(DecimalFormatter.to2Decimal(iob.iobContrib) + " U");
|
||||
holder.activity.setText(DecimalFormatter.to3Decimal(iob.activityContrib) + " U");
|
||||
holder.mealOrCorrection.setText(treatments.get(position).mealBolus ? MainApp.sResources.getString(R.string.mealbolus) : MainApp.sResources.getString(R.string.correctionbous));
|
||||
if (iob.iobContrib != 0)
|
||||
holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.colorAffectingIOB));
|
||||
else
|
||||
holder.dateLinearLayout.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.cardColorBackground));
|
||||
holder.remove.setTag(treatments.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return treatments.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView);
|
||||
}
|
||||
|
||||
public class TreatmentsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
CardView cv;
|
||||
TextView date;
|
||||
TextView insulin;
|
||||
TextView carbs;
|
||||
TextView iob;
|
||||
TextView activity;
|
||||
TextView mealOrCorrection;
|
||||
LinearLayout dateLinearLayout;
|
||||
TextView remove;
|
||||
|
||||
TreatmentsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
cv = (CardView) itemView.findViewById(R.id.treatments_cardview);
|
||||
date = (TextView) itemView.findViewById(R.id.treatments_date);
|
||||
insulin = (TextView) itemView.findViewById(R.id.treatments_insulin);
|
||||
carbs = (TextView) itemView.findViewById(R.id.treatments_carbs);
|
||||
iob = (TextView) itemView.findViewById(R.id.treatments_iob);
|
||||
activity = (TextView) itemView.findViewById(R.id.treatments_activity);
|
||||
mealOrCorrection = (TextView) itemView.findViewById(R.id.treatments_mealorcorrection);
|
||||
dateLinearLayout = (LinearLayout) itemView.findViewById(R.id.treatments_datelinearlayout);
|
||||
remove = (TextView) itemView.findViewById(R.id.treatments_remove);
|
||||
remove.setOnClickListener(this);
|
||||
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final Treatment treatment = (Treatment) v.getTag();
|
||||
switch (v.getId()) {
|
||||
case R.id.treatments_remove:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
||||
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(treatment.created_at));
|
||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
final String _id = treatment._id;
|
||||
if (_id != null && !_id.equals("")) {
|
||||
MainApp.getConfigBuilder().removeCareportalEntryFromNS(_id);
|
||||
}
|
||||
MainApp.getDbHelper().delete(treatment);
|
||||
treatmentsPlugin.initializeData();
|
||||
updateGUI();
|
||||
Answers.getInstance().logCustom(new CustomEvent("RemoveTreatment"));
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
|
||||
builder.show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.treatments_bolus_fragment, container, false);
|
||||
|
||||
recyclerView = (RecyclerView) view.findViewById(R.id.treatments_recyclerview);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
llm = new LinearLayoutManager(view.getContext());
|
||||
recyclerView.setLayoutManager(llm);
|
||||
|
||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.treatments);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
iobTotal = (TextView) view.findViewById(R.id.treatments_iobtotal);
|
||||
activityTotal = (TextView) view.findViewById(R.id.treatments_iobactivitytotal);
|
||||
|
||||
refreshFromNS = (Button) view.findViewById(R.id.treatments_reshreshfromnightscout);
|
||||
refreshFromNS.setOnClickListener(this);
|
||||
|
||||
context = getContext();
|
||||
|
||||
updateGUI();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.treatments_reshreshfromnightscout:
|
||||
boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false);
|
||||
if (nsUploadOnly) {
|
||||
ToastUtils.showToastInUiThread(getContext(), this.getContext().getString(R.string.ns_upload_only_enabled));
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
|
||||
builder.setTitle(this.getContext().getString(R.string.confirmation));
|
||||
builder.setMessage(this.getContext().getString(R.string.refreshtreatmentsfromnightscout));
|
||||
builder.setPositiveButton(this.getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
MainApp.getDbHelper().resetTreatments();
|
||||
treatmentsPlugin.initializeData();
|
||||
updateGUI();
|
||||
Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
|
||||
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(this.getContext().getString(R.string.cancel), null);
|
||||
builder.show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
MainApp.bus().register(this);
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventTreatmentChange ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
public void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||
if (profile == null)
|
||||
return;
|
||||
if (activity != null && recyclerView != null)
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.treatments), false);
|
||||
if (TreatmentsPlugin.lastCalculation != null)
|
||||
iobTotal.setText(DecimalFormatter.to2Decimal(TreatmentsPlugin.lastCalculation.iob) + " U");
|
||||
if (TreatmentsPlugin.lastCalculation != null)
|
||||
activityTotal.setText(DecimalFormatter.to3Decimal(TreatmentsPlugin.lastCalculation.activity) + " U");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -544,10 +544,10 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
}
|
||||
|
||||
//IOB
|
||||
MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB();
|
||||
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round();
|
||||
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB();
|
||||
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round();
|
||||
MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOBTreatments();
|
||||
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculationTreatments().round();
|
||||
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOBTempBasals();
|
||||
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculationTempBasals().round();
|
||||
status += (shortString?"":(getString(R.string.treatments_iob_label_string) + " ")) + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob);
|
||||
|
||||
if (mPrefs.getBoolean("wear_detailediob", true)) {
|
||||
|
|
|
@ -170,10 +170,10 @@ public class StatuslinePlugin implements PluginBase {
|
|||
}
|
||||
|
||||
//IOB
|
||||
MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB();
|
||||
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round();
|
||||
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB();
|
||||
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round();
|
||||
MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOBTreatments();
|
||||
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculationTreatments().round();
|
||||
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOBTempBasals();
|
||||
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculationTempBasals().round();
|
||||
status += (shortString ? "" : (ctx.getString(R.string.treatments_iob_label_string) + " ")) + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob);
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import org.json.JSONObject;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
import info.nightscout.androidaps.interfaces.TempBasalsInterface;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
|
@ -88,13 +87,13 @@ public class BolusWizard {
|
|||
// Insulin from IOB
|
||||
// IOB calculation
|
||||
TreatmentsInterface treatments = ConfigBuilderPlugin.getActiveTreatments();
|
||||
treatments.updateTotalIOB();
|
||||
IobTotal bolusIob = treatments.getLastCalculation();
|
||||
treatments.updateTotalIOBTreatments();
|
||||
IobTotal bolusIob = treatments.getLastCalculationTreatments();
|
||||
TempBasalsInterface tempBasals = ConfigBuilderPlugin.getActiveTempBasals();
|
||||
IobTotal basalIob = new IobTotal(new Date().getTime());
|
||||
if (tempBasals != null) {
|
||||
tempBasals.updateTotalIOB();
|
||||
basalIob = tempBasals.getLastCalculation().round();
|
||||
tempBasals.updateTotalIOBTempBasals();
|
||||
basalIob = tempBasals.getLastCalculationTempBasals().round();
|
||||
}
|
||||
|
||||
insulingFromBolusIOB = includeBolusIOB ? -bolusIob.iob : 0d;
|
||||
|
|
68
app/src/main/res/layout/treatments_bolus_fragment.xml
Normal file
68
app/src/main/res/layout/treatments_bolus_fragment.xml
Normal file
|
@ -0,0 +1,68 @@
|
|||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".plugins.Treatments.fragments.TreatmentsBolusFragment">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/treatments_iobtotal_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/treatments_iobtotal_label_string"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/treatments_iobtotal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/treatments_iobactivitytotal_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/treatments_iobactivitytotal_label_string"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/treatments_iobactivitytotal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/treatments_reshreshfromnightscout"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/nav_refreshtreatments" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/treatments_recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -4,65 +4,19 @@
|
|||
android:layout_height="match_parent"
|
||||
tools:context=".plugins.Treatments.TreatmentsFragment">
|
||||
|
||||
<LinearLayout
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/treatments_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
<android.support.v4.view.PagerTabStrip
|
||||
android:id="@+id/treatments_tabstrip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp">
|
||||
android:layout_height="wrap_content">
|
||||
</android.support.v4.view.PagerTabStrip>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/treatments_iobtotal_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/treatments_iobtotal_label_string"
|
||||
android:textStyle="bold" />
|
||||
</android.support.v4.view.ViewPager>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/treatments_iobtotal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/treatments_iobactivitytotal_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/treatments_iobactivitytotal_label_string"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/treatments_iobactivitytotal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/treatments_reshreshfromnightscout"
|
||||
style="?android:attr/buttonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/nav_refreshtreatments" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/treatments_recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
|
Loading…
Reference in a new issue