Search in sources :

Example 71 with Select

use of com.activeandroid.query.Select in project xDrip-plus by jamorham.

the class DBSearchUtil method noReadingsBelowRange.

public static int noReadingsBelowRange(Context context) {
    Bounds bounds = new Bounds().invoke();
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    boolean mgdl = "mgdl".equals(settings.getString("units", "mgdl"));
    double low = Double.parseDouble(settings.getString("lowValue", "70"));
    if (!mgdl) {
        low *= Constants.MMOLL_TO_MGDL;
    }
    int count = new Select().from(BgReading.class).where("timestamp >= " + bounds.start).where("timestamp <= " + bounds.stop).where("calculated_value > " + CUTOFF).where("calculated_value < " + low).where("snyced == 0").count();
    Log.d("DrawStats", "Low count: " + count);
    return count;
}
Also used : SharedPreferences(android.content.SharedPreferences) Select(com.activeandroid.query.Select)

Example 72 with Select

use of com.activeandroid.query.Select in project xDrip-plus by jamorham.

the class DBSearchUtil method noReadingsAboveRange.

public static int noReadingsAboveRange(Context context) {
    Bounds bounds = new Bounds().invoke();
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    boolean mgdl = "mgdl".equals(settings.getString("units", "mgdl"));
    double high = Double.parseDouble(settings.getString("highValue", "170"));
    if (!mgdl) {
        high *= Constants.MMOLL_TO_MGDL;
    }
    int count = new Select().from(BgReading.class).where("timestamp >= " + bounds.start).where("timestamp <= " + bounds.stop).where("calculated_value > " + CUTOFF).where("calculated_value > " + high).where("snyced == 0").count();
    Log.d("DrawStats", "High count: " + count);
    return count;
}
Also used : SharedPreferences(android.content.SharedPreferences) Select(com.activeandroid.query.Select)

Example 73 with Select

use of com.activeandroid.query.Select in project xDrip-plus by jamorham.

the class SlopeParameters method max_recent.

public static double max_recent() {
    Sensor sensor = Sensor.currentSensor();
    Calibration calibration = new Select().from(Calibration.class).where("Sensor = ? ", sensor.getId()).where("slope_confidence != 0").where("sensor_confidence != 0").where("timestamp > ?", (new Date().getTime() - (60000 * 60 * 24 * 4))).orderBy("bg desc").executeSingle();
    if (calibration != null) {
        return calibration.bg;
    } else {
        return 120;
    }
}
Also used : Select(com.activeandroid.query.Select) Date(java.util.Date)

Example 74 with Select

use of com.activeandroid.query.Select in project xDrip-plus by jamorham.

the class AlertType method toSettings.

// Convert all settings to a string and save it in the references. This is needed to allow it's backup.
public static boolean toSettings(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    List<AlertType> alerts = new Select().from(AlertType.class).execute();
    Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().registerTypeAdapter(Date.class, new DateTypeAdapter()).serializeSpecialFloatingPointValues().create();
    String output = gson.toJson(alerts);
    Log.e(TAG, "Created the string " + output);
    prefs.edit().putString("saved_alerts", output).commit();
    return true;
}
Also used : DateTypeAdapter(com.google.gson.internal.bind.DateTypeAdapter) SharedPreferences(android.content.SharedPreferences) GsonBuilder(com.google.gson.GsonBuilder) Select(com.activeandroid.query.Select) Gson(com.google.gson.Gson)

Example 75 with Select

use of com.activeandroid.query.Select in project xDrip-plus by jamorham.

the class Treatments method latestForGraphSystime.

public static List<Treatments> latestForGraphSystime(int number, double startTime, double endTime) {
    fixUpTable();
    DecimalFormat df = new DecimalFormat("#");
    // are there decimal points in the database??
    df.setMaximumFractionDigits(1);
    return new Select().from(Treatments.class).where("systimestamp >= ? and systimestamp <= ?", df.format(startTime), df.format(endTime)).orderBy("systimestamp asc").limit(number).execute();
}
Also used : DecimalFormat(java.text.DecimalFormat) Select(com.activeandroid.query.Select)

Aggregations

Select (com.activeandroid.query.Select)80 SharedPreferences (android.content.SharedPreferences)14 From (com.activeandroid.query.From)11 MockModel (com.activeandroid.test.MockModel)11 DecimalFormat (java.text.DecimalFormat)8 ArrayList (java.util.ArrayList)7 Date (java.util.Date)7 Cursor (android.database.Cursor)6 ActiveBluetoothDevice (com.eveningoutpost.dexdrip.Models.ActiveBluetoothDevice)6 JSONException (org.json.JSONException)5 GsonBuilder (com.google.gson.GsonBuilder)4 PendingIntent (android.app.PendingIntent)2 BluetoothDevice (android.bluetooth.BluetoothDevice)2 Intent (android.content.Intent)2 Update (com.activeandroid.query.Update)2 BgReading (com.eveningoutpost.dexdrip.Models.BgReading)2 MissedReadingService (com.eveningoutpost.dexdrip.Services.MissedReadingService)2 Gson (com.google.gson.Gson)2 DateTypeAdapter (com.google.gson.internal.bind.DateTypeAdapter)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2