rename identical functions

This commit is contained in:
Milos Kozak 2017-05-11 18:54:50 +02:00
parent 72f3efc39a
commit a0d31b2118
19 changed files with 432 additions and 336 deletions

View file

@ -115,10 +115,10 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
if (danaRPlugin.isEnabled(PluginBase.PUMP) || danaRKoreanPlugin.isEnabled(PluginBase.PUMP)) { if (danaRPlugin.isEnabled(PluginBase.PUMP) || danaRKoreanPlugin.isEnabled(PluginBase.PUMP)) {
addPreferencesFromResource(R.xml.pref_danar); addPreferencesFromResource(R.xml.pref_danar);
} }
if (danaRv2Plugin.isEnabled(PluginBase.PUMP)) { if (danaRv2Plugin != null && danaRv2Plugin.isEnabled(PluginBase.PUMP)) {
addPreferencesFromResource(R.xml.pref_danarv2); 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); addPreferencesFromResource(R.xml.pref_danarprofile);
} }
} }

View file

@ -9,9 +9,9 @@ import info.nightscout.androidaps.data.IobTotal;
* Created by mike on 14.06.2016. * Created by mike on 14.06.2016.
*/ */
public interface TempBasalsInterface { public interface TempBasalsInterface {
void updateTotalIOB(); void updateTotalIOBTempBasals();
IobTotal getLastCalculation(); IobTotal getLastCalculationTempBasals();
IobTotal getCalculationToTime(long time); IobTotal getCalculationToTimeTempBasals(long time);
TempBasal getTempBasal (Date time); TempBasal getTempBasal (Date time);
TempBasal getExtendedBolus (Date time); TempBasal getExtendedBolus (Date time);

View file

@ -11,9 +11,9 @@ import info.nightscout.androidaps.data.IobTotal;
*/ */
public interface TreatmentsInterface { public interface TreatmentsInterface {
void updateTotalIOB(); void updateTotalIOBTreatments();
IobTotal getLastCalculation(); IobTotal getLastCalculationTreatments();
IobTotal getCalculationToTime(long time); IobTotal getCalculationToTimeTreatments(long time);
MealData getMealData(); MealData getMealData();
List<Treatment> getTreatments(); List<Treatment> getTreatments();
List<Treatment> getTreatments5MinBack(long time); List<Treatment> getTreatments5MinBack(long time);

View file

@ -16,7 +16,6 @@ import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
@ -339,8 +338,8 @@ public class IobCobCalculatorPlugin implements PluginBase {
} else { } else {
//log.debug(">>> Cache miss " + new Date(time).toLocaleString()); //log.debug(">>> Cache miss " + new Date(time).toLocaleString());
} }
IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getCalculationToTime(time).round(); IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getCalculationToTimeTreatments(time).round();
IobTotal basalIob = ConfigBuilderPlugin.getActiveTempBasals().getCalculationToTime(time).round(); IobTotal basalIob = ConfigBuilderPlugin.getActiveTempBasals().getCalculationToTimeTempBasals(time).round();
/* /*
if (basalIob.basaliob > 0) { if (basalIob.basaliob > 0) {
log.debug(new Date(time).toLocaleString() + " basaliob: " + basalIob.basaliob ); log.debug(new Date(time).toLocaleString() + " basaliob: " + basalIob.basaliob );

View file

@ -189,10 +189,10 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
Date start = new Date(); Date start = new Date();
TreatmentsInterface treatments = MainApp.getConfigBuilder().getActiveTreatments(); TreatmentsInterface treatments = MainApp.getConfigBuilder().getActiveTreatments();
TempBasalsInterface tempBasals = MainApp.getConfigBuilder().getActiveTempBasals(); TempBasalsInterface tempBasals = MainApp.getConfigBuilder().getActiveTempBasals();
treatments.updateTotalIOB(); treatments.updateTotalIOBTreatments();
tempBasals.updateTotalIOB(); tempBasals.updateTotalIOBTempBasals();
IobTotal bolusIob = treatments.getLastCalculation(); IobTotal bolusIob = treatments.getLastCalculationTreatments();
IobTotal basalIob = tempBasals.getLastCalculation(); IobTotal basalIob = tempBasals.getLastCalculationTempBasals();
IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob).round(); IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob).round();

View file

@ -34,7 +34,6 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.w3c.dom.Text;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -52,10 +51,8 @@ import info.nightscout.androidaps.interfaces.TempBasalsInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.data.IobTotal; 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.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile; 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.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.utils.BolusWizard; import info.nightscout.utils.BolusWizard;
@ -414,13 +411,13 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Co
// IOB calculation // IOB calculation
TreatmentsInterface treatments = ConfigBuilderPlugin.getActiveTreatments(); TreatmentsInterface treatments = ConfigBuilderPlugin.getActiveTreatments();
treatments.updateTotalIOB(); treatments.updateTotalIOBTreatments();
IobTotal bolusIob = treatments.getLastCalculation(); IobTotal bolusIob = treatments.getLastCalculationTreatments();
TempBasalsInterface tempBasals = ConfigBuilderPlugin.getActiveTempBasals(); TempBasalsInterface tempBasals = ConfigBuilderPlugin.getActiveTempBasals();
IobTotal basalIob = new IobTotal(new Date().getTime()); IobTotal basalIob = new IobTotal(new Date().getTime());
if (tempBasals != null) { if (tempBasals != null) {
tempBasals.updateTotalIOB(); tempBasals.updateTotalIOBTempBasals();
basalIob = tempBasals.getLastCalculation().round(); basalIob = tempBasals.getLastCalculationTempBasals().round();
} }
bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U"); bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U");

View file

@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.Overview;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.DashPathEffect; import android.graphics.DashPathEffect;
import android.graphics.Paint; import android.graphics.Paint;
@ -16,23 +15,19 @@ import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView; import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.HapticFeedbackConstants; import android.view.HapticFeedbackConstants;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.Answers;
@ -63,11 +58,9 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.PreferencesActivity;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.GlucoseStatus;
import info.nightscout.androidaps.data.IobTotal; 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.TempBasal;
import info.nightscout.androidaps.db.TempTarget; import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventNewBasalProfile; 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.BolusWizard;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter; 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.Round;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
import info.nightscout.utils.ToastUtils; 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)); timeAgoView.setText(String.format(MainApp.sResources.getString(R.string.minago), agoMin));
// iob // iob
ConfigBuilderPlugin.getActiveTreatments().updateTotalIOB(); ConfigBuilderPlugin.getActiveTreatments().updateTotalIOBTreatments();
IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculation().round(); IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculationTreatments().round();
IobTotal basalIob = new IobTotal(new Date().getTime()); IobTotal basalIob = new IobTotal(new Date().getTime());
if (ConfigBuilderPlugin.getActiveTempBasals() != null) { if (ConfigBuilderPlugin.getActiveTempBasals() != null) {
ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOB(); ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOBTempBasals();
basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculation().round(); basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculationTempBasals().round();
} }
String iobtext = getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U (" String iobtext = getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("

View file

@ -144,12 +144,12 @@ public class PersistentNotificationPlugin implements PluginBase{
} }
//IOB //IOB
ConfigBuilderPlugin.getActiveTreatments().updateTotalIOB(); ConfigBuilderPlugin.getActiveTreatments().updateTotalIOBTreatments();
IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculation().round(); IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculationTreatments().round();
IobTotal basalIob = new IobTotal(new Date().getTime()); IobTotal basalIob = new IobTotal(new Date().getTime());
if (ConfigBuilderPlugin.getActiveTempBasals() != null) { if (ConfigBuilderPlugin.getActiveTempBasals() != null) {
ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOB(); ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOBTempBasals();
basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculation().round(); basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculationTempBasals().round();
} }
String line2 = ctx.getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U (" 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 " + ctx.getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "

View file

@ -36,12 +36,12 @@ import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
import info.nightscout.androidaps.plugins.Overview.Notification; import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; 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.DateUtil;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.Round; import info.nightscout.utils.Round;

View file

@ -43,8 +43,6 @@ import info.nightscout.utils.SP;
import info.nightscout.utils.SafeParse; import info.nightscout.utils.SafeParse;
import info.nightscout.utils.XdripCalibrations; import info.nightscout.utils.XdripCalibrations;
import static info.nightscout.androidaps.R.string.profile;
/** /**
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
@ -256,10 +254,10 @@ public class SmsCommunicatorPlugin implements PluginBase {
if (glucoseStatus != null) if (glucoseStatus != null)
reply += MainApp.sResources.getString(R.string.sms_delta) + " " + NSProfile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", "; reply += MainApp.sResources.getString(R.string.sms_delta) + " " + NSProfile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", ";
ConfigBuilderPlugin.getActiveTreatments().updateTotalIOB(); ConfigBuilderPlugin.getActiveTreatments().updateTotalIOBTreatments();
IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculation().round(); IobTotal bolusIob = ConfigBuilderPlugin.getActiveTreatments().getLastCalculationTreatments().round();
ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOB(); ConfigBuilderPlugin.getActiveTempBasals().updateTotalIOBTempBasals();
IobTotal basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculation().round(); IobTotal basalIob = ConfigBuilderPlugin.getActiveTempBasals().getLastCalculationTempBasals().round();
reply += MainApp.sResources.getString(R.string.sms_iob) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U (" 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 " + MainApp.sResources.getString(R.string.sms_bolus) + " " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "

View file

@ -176,16 +176,16 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface {
public void updateTotalIOBIfNeeded() { public void updateTotalIOBIfNeeded() {
if (lastCalculationTimestamp > new Date().getTime() - 60 * 1000) if (lastCalculationTimestamp > new Date().getTime() - 60 * 1000)
return; return;
updateTotalIOB(); updateTotalIOBTempBasals();
} }
@Override @Override
public IobTotal getLastCalculation() { public IobTotal getLastCalculationTempBasals() {
return lastCalculation; return lastCalculation;
} }
@Override @Override
public IobTotal getCalculationToTime(long time) { public IobTotal getCalculationToTimeTempBasals(long time) {
checkForExpired(tempBasals); checkForExpired(tempBasals);
checkForExpired(extendedBoluses); checkForExpired(extendedBoluses);
IobTotal total = new IobTotal(time); IobTotal total = new IobTotal(time);
@ -208,8 +208,8 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface {
} }
@Override @Override
public void updateTotalIOB() { public void updateTotalIOBTempBasals() {
IobTotal total = getCalculationToTime(new Date().getTime()); IobTotal total = getCalculationToTimeTempBasals(new Date().getTime());
lastCalculationTimestamp = new Date().getTime(); lastCalculationTimestamp = new Date().getTime();
lastCalculation = total; lastCalculation = total;

View file

@ -1,51 +1,23 @@
package info.nightscout.androidaps.plugins.Treatments; package info.nightscout.androidaps.plugins.Treatments;
import android.app.Activity;
import android.content.Context; 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.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat; import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog; import android.support.v4.app.FragmentPagerAdapter;
import android.support.v7.widget.CardView; import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; 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.Logger;
import org.slf4j.LoggerFactory; 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.R;
import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsBolusFragment;
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;
public class TreatmentsFragment extends Fragment implements View.OnClickListener { public class TreatmentsFragment extends Fragment {
private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class); private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class);
private static TreatmentsPlugin treatmentsPlugin = new TreatmentsPlugin(); private static TreatmentsPlugin treatmentsPlugin = new TreatmentsPlugin();
@ -54,112 +26,53 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
return treatmentsPlugin; return treatmentsPlugin;
} }
RecyclerView recyclerView; SectionsPagerAdapter sectionsPagerAdapter;
LinearLayoutManager llm; ViewPager viewPager;
TextView iobTotal;
TextView activityTotal;
Button refreshFromNS;
Context context; Context context;
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TreatmentsViewHolder> { Fragment bolusFragment;
List<Treatment> treatments; public class SectionsPagerAdapter extends FragmentPagerAdapter {
RecyclerViewAdapter(List<Treatment> treatments) { public SectionsPagerAdapter(FragmentManager fm) {
this.treatments = treatments; super(fm);
} }
@Override @Override
public TreatmentsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { public Fragment getItem(int position) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_item, viewGroup, false); // getItem is called to instantiate the fragment for the given page.
return new TreatmentsViewHolder(v); switch (position){
case 0:
return bolusFragment;
case 1:
return new Fragment();
/*
case 2:
return iobcobActiveFragmentObject;
case 3:
return basalvsTempBasalObject;
*/
default:
return null;
}
} }
@Override @Override
public void onBindViewHolder(TreatmentsViewHolder holder, int position) { public int getCount() {
if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet // Show 1 total pages.
return; return 2;
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 @Override
public int getItemCount() { public CharSequence getPageTitle(int position) {
return treatments.size(); switch (position) {
} case 0:
return getString(R.string.bolus);
@Override case 1:
public void onAttachedToRecyclerView(RecyclerView recyclerView) { return "Empty";
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;
}
} }
return null;
} }
} }
@ -168,87 +81,13 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
Bundle savedInstanceState) { Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.treatments_fragment, container, false); View view = inflater.inflate(R.layout.treatments_fragment, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.treatments_recyclerview); bolusFragment = new TreatmentsBolusFragment();
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);
sectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager());
viewPager = (ViewPager) view.findViewById(R.id.treatments_pager);
viewPager.setAdapter(sectionsPagerAdapter);
context = getContext(); context = getContext();
updateGUI();
return view; 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");
}
});
}
} }

View file

@ -120,16 +120,16 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
public void updateTotalIOBIfNeeded() { public void updateTotalIOBIfNeeded() {
if (lastCalculationTimestamp > new Date().getTime() - 60 * 1000) if (lastCalculationTimestamp > new Date().getTime() - 60 * 1000)
return; return;
updateTotalIOB(); updateTotalIOBTreatments();
} }
@Override @Override
public IobTotal getLastCalculation() { public IobTotal getLastCalculationTreatments() {
return lastCalculation; return lastCalculation;
} }
@Override @Override
public IobTotal getCalculationToTime(long time) { public IobTotal getCalculationToTimeTreatments(long time) {
IobTotal total = new IobTotal(time); IobTotal total = new IobTotal(time);
if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet if (MainApp.getConfigBuilder() == null || ConfigBuilderPlugin.getActiveProfile() == null) // app not initialized yet
@ -154,8 +154,8 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
} }
@Override @Override
public void updateTotalIOB() { public void updateTotalIOBTreatments() {
IobTotal total = getCalculationToTime(new Date().getTime()); IobTotal total = getCalculationToTimeTreatments(new Date().getTime());
lastCalculationTimestamp = new Date().getTime(); lastCalculationTimestamp = new Date().getTime();
lastCalculation = total; lastCalculation = total;
@ -209,7 +209,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Subscribe @Subscribe
public void onStatusEvent(final EventTreatmentChange ev) { public void onStatusEvent(final EventTreatmentChange ev) {
initializeData(); initializeData();
updateTotalIOB(); updateTotalIOBTreatments();
} }
} }

View file

@ -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");
}
});
}
}

View file

@ -544,10 +544,10 @@ public class WatchUpdaterService extends WearableListenerService implements
} }
//IOB //IOB
MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB(); MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOBTreatments();
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round(); IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculationTreatments().round();
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB(); MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOBTempBasals();
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round(); IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculationTempBasals().round();
status += (shortString?"":(getString(R.string.treatments_iob_label_string) + " ")) + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob); status += (shortString?"":(getString(R.string.treatments_iob_label_string) + " ")) + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob);
if (mPrefs.getBoolean("wear_detailediob", true)) { if (mPrefs.getBoolean("wear_detailediob", true)) {

View file

@ -170,10 +170,10 @@ public class StatuslinePlugin implements PluginBase {
} }
//IOB //IOB
MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOB(); MainApp.getConfigBuilder().getActiveTreatments().updateTotalIOBTreatments();
IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculation().round(); IobTotal bolusIob = MainApp.getConfigBuilder().getActiveTreatments().getLastCalculationTreatments().round();
MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOB(); MainApp.getConfigBuilder().getActiveTempBasals().updateTotalIOBTempBasals();
IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculation().round(); IobTotal basalIob = MainApp.getConfigBuilder().getActiveTempBasals().getLastCalculationTempBasals().round();
status += (shortString ? "" : (ctx.getString(R.string.treatments_iob_label_string) + " ")) + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob); status += (shortString ? "" : (ctx.getString(R.string.treatments_iob_label_string) + " ")) + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob);

View file

@ -4,7 +4,6 @@ import org.json.JSONObject;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.GlucoseStatus;
import info.nightscout.androidaps.interfaces.TempBasalsInterface; import info.nightscout.androidaps.interfaces.TempBasalsInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
@ -88,13 +87,13 @@ public class BolusWizard {
// Insulin from IOB // Insulin from IOB
// IOB calculation // IOB calculation
TreatmentsInterface treatments = ConfigBuilderPlugin.getActiveTreatments(); TreatmentsInterface treatments = ConfigBuilderPlugin.getActiveTreatments();
treatments.updateTotalIOB(); treatments.updateTotalIOBTreatments();
IobTotal bolusIob = treatments.getLastCalculation(); IobTotal bolusIob = treatments.getLastCalculationTreatments();
TempBasalsInterface tempBasals = ConfigBuilderPlugin.getActiveTempBasals(); TempBasalsInterface tempBasals = ConfigBuilderPlugin.getActiveTempBasals();
IobTotal basalIob = new IobTotal(new Date().getTime()); IobTotal basalIob = new IobTotal(new Date().getTime());
if (tempBasals != null) { if (tempBasals != null) {
tempBasals.updateTotalIOB(); tempBasals.updateTotalIOBTempBasals();
basalIob = tempBasals.getLastCalculation().round(); basalIob = tempBasals.getLastCalculationTempBasals().round();
} }
insulingFromBolusIOB = includeBolusIOB ? -bolusIob.iob : 0d; insulingFromBolusIOB = includeBolusIOB ? -bolusIob.iob : 0d;

View 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>

View file

@ -4,65 +4,19 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".plugins.Treatments.TreatmentsFragment"> tools:context=".plugins.Treatments.TreatmentsFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout <android.support.v4.view.ViewPager
android:layout_width="match_parent" android:id="@+id/treatments_pager"
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_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView> <android.support.v4.view.PagerTabStrip
android:id="@+id/treatments_tabstrip"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v4.view.PagerTabStrip>
</android.support.v4.view.ViewPager>
</LinearLayout>
</FrameLayout> </FrameLayout>