diff --git a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java index e5e8aac528..17adbfb736 100644 --- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java +++ b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java @@ -6,6 +6,7 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.os.HandlerThread; +import android.support.annotation.Nullable; import com.j256.ormlite.dao.Dao; import com.j256.ormlite.stmt.PreparedQuery; @@ -332,6 +333,7 @@ public class DataService extends IntentService { editor.commit(); } + @Nullable public static Treatment findById(String _id) { try { QueryBuilder qb = null; @@ -355,6 +357,7 @@ public class DataService extends IntentService { return null; } + @Nullable public static Treatment findByTimeIndex(Long timeIndex) { try { QueryBuilder qb = null; diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index 0f7fb1ef48..558381b061 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -8,6 +8,7 @@ import java.util.List; import android.content.Context; import android.database.sqlite.SQLiteDatabase; +import android.support.annotation.Nullable; import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper; import com.j256.ormlite.dao.Dao; @@ -109,6 +110,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { /* * Return last BgReading from database or null if db is empty */ + @Nullable public BgReading lastBg() { List bgList = null; @@ -133,6 +135,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { * Return bg reading if not old ( <9 min ) * or null if older */ + @Nullable public BgReading actualBg() { BgReading lastBg = lastBg(); @@ -182,6 +185,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } } + @Nullable public GlucoseStatus getGlucoseStatusData() { GlucoseStatus result = new GlucoseStatus(); try { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 4dccba83fd..d7d808a93d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -105,7 +105,8 @@ public class OverviewFragment extends Fragment implements PluginBase { if (profile != null && lastBG != null && bgView != null) { bgView.setText(lastBG.valueToUnitsToString(profile.getUnits())); DatabaseHelper.GlucoseStatus glucoseStatus = MainApp.getDbHelper().getGlucoseStatusData(); - deltaView.setText("Δ " + NSProfile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units); + if (glucoseStatus != null) + deltaView.setText("Δ " + NSProfile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units); BgReading.units = profile.getUnits(); } else return; diff --git a/app/src/main/java/info/nightscout/androidaps/tabs/TabPageAdapter.java b/app/src/main/java/info/nightscout/androidaps/tabs/TabPageAdapter.java index 550065bcc2..46668d2d97 100644 --- a/app/src/main/java/info/nightscout/androidaps/tabs/TabPageAdapter.java +++ b/app/src/main/java/info/nightscout/androidaps/tabs/TabPageAdapter.java @@ -1,6 +1,7 @@ package info.nightscout.androidaps.tabs; import android.os.Bundle; +import android.support.annotation.Nullable; import android.support.annotation.PluralsRes; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; @@ -24,6 +25,7 @@ public class TabPageAdapter extends FragmentPagerAdapter { } @Override + @Nullable public Fragment getItem(int position) { if (position > registeredTabs) return null;