add @Nullable where possible

This commit is contained in:
Milos Kozak 2016-06-12 14:18:21 +02:00
parent f15fdf613f
commit 7e3d1e6ad4
4 changed files with 11 additions and 1 deletions

View file

@ -6,6 +6,7 @@ import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
import android.support.annotation.Nullable;
import com.j256.ormlite.dao.Dao; import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.PreparedQuery; import com.j256.ormlite.stmt.PreparedQuery;
@ -332,6 +333,7 @@ public class DataService extends IntentService {
editor.commit(); editor.commit();
} }
@Nullable
public static Treatment findById(String _id) { public static Treatment findById(String _id) {
try { try {
QueryBuilder<Treatment, String> qb = null; QueryBuilder<Treatment, String> qb = null;
@ -355,6 +357,7 @@ public class DataService extends IntentService {
return null; return null;
} }
@Nullable
public static Treatment findByTimeIndex(Long timeIndex) { public static Treatment findByTimeIndex(Long timeIndex) {
try { try {
QueryBuilder<Treatment, String> qb = null; QueryBuilder<Treatment, String> qb = null;

View file

@ -8,6 +8,7 @@ import java.util.List;
import android.content.Context; import android.content.Context;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.support.annotation.Nullable;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper; import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.dao.Dao; 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 * Return last BgReading from database or null if db is empty
*/ */
@Nullable
public BgReading lastBg() { public BgReading lastBg() {
List<BgReading> bgList = null; List<BgReading> bgList = null;
@ -133,6 +135,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
* Return bg reading if not old ( <9 min ) * Return bg reading if not old ( <9 min )
* or null if older * or null if older
*/ */
@Nullable
public BgReading actualBg() { public BgReading actualBg() {
BgReading lastBg = lastBg(); BgReading lastBg = lastBg();
@ -182,6 +185,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
} }
@Nullable
public GlucoseStatus getGlucoseStatusData() { public GlucoseStatus getGlucoseStatusData() {
GlucoseStatus result = new GlucoseStatus(); GlucoseStatus result = new GlucoseStatus();
try { try {

View file

@ -105,6 +105,7 @@ public class OverviewFragment extends Fragment implements PluginBase {
if (profile != null && lastBG != null && bgView != null) { if (profile != null && lastBG != null && bgView != null) {
bgView.setText(lastBG.valueToUnitsToString(profile.getUnits())); bgView.setText(lastBG.valueToUnitsToString(profile.getUnits()));
DatabaseHelper.GlucoseStatus glucoseStatus = MainApp.getDbHelper().getGlucoseStatusData(); DatabaseHelper.GlucoseStatus glucoseStatus = MainApp.getDbHelper().getGlucoseStatusData();
if (glucoseStatus != null)
deltaView.setText("Δ " + NSProfile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units); deltaView.setText("Δ " + NSProfile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units);
BgReading.units = profile.getUnits(); BgReading.units = profile.getUnits();
} else } else

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.tabs; package info.nightscout.androidaps.tabs;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.PluralsRes; import android.support.annotation.PluralsRes;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
@ -24,6 +25,7 @@ public class TabPageAdapter extends FragmentPagerAdapter {
} }
@Override @Override
@Nullable
public Fragment getItem(int position) { public Fragment getItem(int position) {
if (position > registeredTabs) if (position > registeredTabs)
return null; return null;