more checks for null profile
This commit is contained in:
parent
6e5d5c4a26
commit
3f29ca3b96
11 changed files with 49 additions and 18 deletions
|
@ -13,6 +13,7 @@ import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.jjoe64.graphview.GraphView;
|
import com.jjoe64.graphview.GraphView;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
@ -58,6 +59,8 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
GraphView iobGraph;
|
GraphView iobGraph;
|
||||||
@BindView(R.id.historybrowse_seekBar)
|
@BindView(R.id.historybrowse_seekBar)
|
||||||
SeekBar seekBar;
|
SeekBar seekBar;
|
||||||
|
@BindView(R.id.historybrowse_noprofile)
|
||||||
|
TextView noProfile;
|
||||||
|
|
||||||
private int rangeToDisplay = 24; // for graph
|
private int rangeToDisplay = 24; // for graph
|
||||||
private long start;
|
private long start;
|
||||||
|
@ -182,6 +185,14 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
||||||
void updateGUI(String from) {
|
void updateGUI(String from) {
|
||||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
|
||||||
|
if (profile == null) {
|
||||||
|
noProfile.setVisibility(View.VISIBLE);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
noProfile.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
final String units = profile.getUnits();
|
final String units = profile.getUnits();
|
||||||
|
|
||||||
double lowLineSetting = SP.getDouble("low_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units));
|
double lowLineSetting = SP.getDouble("low_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units));
|
||||||
|
|
|
@ -181,7 +181,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
profileSpinner.setSelection(p);
|
profileSpinner.setSelection(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile != null ? profile.getUnits() : Constants.MGDL);
|
final Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, units);
|
||||||
|
|
||||||
// temp target
|
// temp target
|
||||||
final ArrayList<CharSequence> reasonList = new ArrayList<CharSequence>();
|
final ArrayList<CharSequence> reasonList = new ArrayList<CharSequence>();
|
||||||
|
|
|
@ -444,15 +444,15 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateInsulin() {
|
private void calculateInsulin() {
|
||||||
ProfileStore profile = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
|
ProfileStore profileStore = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
|
||||||
if (profileSpinner == null || profileSpinner.getSelectedItem() == null)
|
if (profileSpinner == null || profileSpinner.getSelectedItem() == null || profileStore == null)
|
||||||
return; // not initialized yet
|
return; // not initialized yet
|
||||||
String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString();
|
String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString();
|
||||||
Profile specificProfile;
|
Profile specificProfile;
|
||||||
if (selectedAlternativeProfile.equals(MainApp.sResources.getString(R.string.active)))
|
if (selectedAlternativeProfile.equals(MainApp.sResources.getString(R.string.active)))
|
||||||
specificProfile = MainApp.getConfigBuilder().getProfile();
|
specificProfile = MainApp.getConfigBuilder().getProfile();
|
||||||
else
|
else
|
||||||
specificProfile = profile.getSpecificProfile(selectedAlternativeProfile);
|
specificProfile = profileStore.getSpecificProfile(selectedAlternativeProfile);
|
||||||
|
|
||||||
// Entered values
|
// Entered values
|
||||||
Double c_bg = SafeParse.stringToDouble(editBg.getText());
|
Double c_bg = SafeParse.stringToDouble(editBg.getText());
|
||||||
|
|
|
@ -114,6 +114,12 @@ public class SensitivityOref0Plugin implements PluginBase, SensitivityInterface
|
||||||
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
|
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
|
||||||
|
if (profile == null) {
|
||||||
|
log.debug("No profile");
|
||||||
|
return new AutosensResult();
|
||||||
|
}
|
||||||
|
|
||||||
if (autosensDataTable == null || autosensDataTable.size() < 4) {
|
if (autosensDataTable == null || autosensDataTable.size() < 4) {
|
||||||
log.debug("No autosens data available");
|
log.debug("No autosens data available");
|
||||||
|
@ -159,8 +165,6 @@ public class SensitivityOref0Plugin implements PluginBase, SensitivityInterface
|
||||||
Double[] deviations = new Double[deviationsArray.size()];
|
Double[] deviations = new Double[deviationsArray.size()];
|
||||||
deviations = deviationsArray.toArray(deviations);
|
deviations = deviationsArray.toArray(deviations);
|
||||||
|
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
|
||||||
|
|
||||||
double sens = profile.getIsf();
|
double sens = profile.getIsf();
|
||||||
|
|
||||||
double ratio = 1;
|
double ratio = 1;
|
||||||
|
|
|
@ -142,16 +142,18 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeTreatmentData() {
|
private static void initializeTreatmentData() {
|
||||||
// Treatments
|
double dia = Constants.defaultDIA;
|
||||||
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
|
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
||||||
|
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
||||||
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
||||||
|
|
||||||
treatments = MainApp.getDbHelper().getTreatmentDataFromTime(fromMills, false);
|
treatments = MainApp.getDbHelper().getTreatmentDataFromTime(fromMills, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeTempBasalData() {
|
private static void initializeTempBasalData() {
|
||||||
// Treatments
|
double dia = Constants.defaultDIA;
|
||||||
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
|
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
||||||
|
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
||||||
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
||||||
|
|
||||||
tempBasals.reset().add(MainApp.getDbHelper().getTemporaryBasalsDataFromTime(fromMills, false));
|
tempBasals.reset().add(MainApp.getDbHelper().getTemporaryBasalsDataFromTime(fromMills, false));
|
||||||
|
@ -159,8 +161,9 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeExtendedBolusData() {
|
private static void initializeExtendedBolusData() {
|
||||||
// Treatments
|
double dia = Constants.defaultDIA;
|
||||||
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
|
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
||||||
|
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
||||||
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
||||||
|
|
||||||
extendedBoluses.reset().add(MainApp.getDbHelper().getExtendedBolusDataFromTime(fromMills, false));
|
extendedBoluses.reset().add(MainApp.getDbHelper().getExtendedBolusDataFromTime(fromMills, false));
|
||||||
|
|
|
@ -389,8 +389,10 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
if (tb1 != null) {
|
if (tb1 != null) {
|
||||||
tb_before = beginBasalValue;
|
tb_before = beginBasalValue;
|
||||||
Profile profileTB = MainApp.getConfigBuilder().getProfile(runningTime);
|
Profile profileTB = MainApp.getConfigBuilder().getProfile(runningTime);
|
||||||
tb_amount = tb1.tempBasalConvertedToAbsolute(runningTime, profileTB);
|
if (profileTB != null) {
|
||||||
tb_start = runningTime;
|
tb_amount = tb1.tempBasalConvertedToAbsolute(runningTime, profileTB);
|
||||||
|
tb_start = runningTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,17 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/historybrowse_noprofile"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:text="@string/noprofileset"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
|
android:textColor="@android:color/holo_red_light"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -234,7 +234,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:text="23 g" />
|
android:text="" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,7 @@
|
||||||
android:id="@+id/overview_cob"
|
android:id="@+id/overview_cob"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="23 g"
|
android:text=""
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
|
|
@ -366,7 +366,7 @@
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:text="23 g"
|
android:text=""
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
|
|
@ -228,7 +228,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:text="23 g" />
|
android:text="" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue