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.ImageButton;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.jjoe64.graphview.GraphView;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
@ -58,6 +59,8 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
|||
GraphView iobGraph;
|
||||
@BindView(R.id.historybrowse_seekBar)
|
||||
SeekBar seekBar;
|
||||
@BindView(R.id.historybrowse_noprofile)
|
||||
TextView noProfile;
|
||||
|
||||
private int rangeToDisplay = 24; // for graph
|
||||
private long start;
|
||||
|
@ -182,6 +185,14 @@ public class HistoryBrowseActivity extends AppCompatActivity {
|
|||
void updateGUI(String from) {
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
|
||||
if (profile == null) {
|
||||
noProfile.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
} else {
|
||||
noProfile.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
final String units = profile.getUnits();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
final ArrayList<CharSequence> reasonList = new ArrayList<CharSequence>();
|
||||
|
|
|
@ -444,15 +444,15 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
}
|
||||
|
||||
private void calculateInsulin() {
|
||||
ProfileStore profile = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
|
||||
if (profileSpinner == null || profileSpinner.getSelectedItem() == null)
|
||||
ProfileStore profileStore = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
|
||||
if (profileSpinner == null || profileSpinner.getSelectedItem() == null || profileStore == null)
|
||||
return; // not initialized yet
|
||||
String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString();
|
||||
Profile specificProfile;
|
||||
if (selectedAlternativeProfile.equals(MainApp.sResources.getString(R.string.active)))
|
||||
specificProfile = MainApp.getConfigBuilder().getProfile();
|
||||
else
|
||||
specificProfile = profile.getSpecificProfile(selectedAlternativeProfile);
|
||||
specificProfile = profileStore.getSpecificProfile(selectedAlternativeProfile);
|
||||
|
||||
// Entered values
|
||||
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);
|
||||
|
||||
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) {
|
||||
log.debug("No autosens data available");
|
||||
|
@ -159,8 +165,6 @@ public class SensitivityOref0Plugin implements PluginBase, SensitivityInterface
|
|||
Double[] deviations = new Double[deviationsArray.size()];
|
||||
deviations = deviationsArray.toArray(deviations);
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
|
||||
double sens = profile.getIsf();
|
||||
|
||||
double ratio = 1;
|
||||
|
|
|
@ -142,16 +142,18 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
}
|
||||
|
||||
private static void initializeTreatmentData() {
|
||||
// Treatments
|
||||
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
|
||||
double dia = Constants.defaultDIA;
|
||||
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
||||
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
||||
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
||||
|
||||
treatments = MainApp.getDbHelper().getTreatmentDataFromTime(fromMills, false);
|
||||
}
|
||||
|
||||
private static void initializeTempBasalData() {
|
||||
// Treatments
|
||||
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
|
||||
double dia = Constants.defaultDIA;
|
||||
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
||||
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
||||
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
||||
|
||||
tempBasals.reset().add(MainApp.getDbHelper().getTemporaryBasalsDataFromTime(fromMills, false));
|
||||
|
@ -159,8 +161,9 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
}
|
||||
|
||||
private static void initializeExtendedBolusData() {
|
||||
// Treatments
|
||||
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
|
||||
double dia = Constants.defaultDIA;
|
||||
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
||||
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
||||
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
||||
|
||||
extendedBoluses.reset().add(MainApp.getDbHelper().getExtendedBolusDataFromTime(fromMills, false));
|
||||
|
|
|
@ -389,9 +389,11 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
if (tb1 != null) {
|
||||
tb_before = beginBasalValue;
|
||||
Profile profileTB = MainApp.getConfigBuilder().getProfile(runningTime);
|
||||
if (profileTB != null) {
|
||||
tb_amount = tb1.tempBasalConvertedToAbsolute(runningTime, profileTB);
|
||||
tb_start = runningTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (; runningTime < now; runningTime += 5 * 60 * 1000) {
|
||||
|
|
|
@ -11,6 +11,17 @@
|
|||
android:layout_height="match_parent"
|
||||
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
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -234,7 +234,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="23 g" />
|
||||
android:text="" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -313,7 +313,7 @@
|
|||
android:id="@+id/overview_cob"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="23 g"
|
||||
android:text=""
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
|
|
|
@ -366,7 +366,7 @@
|
|||
android:gravity="start"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="23 g"
|
||||
android:text=""
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="23 g" />
|
||||
android:text="" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue