Search in sources :

Example 26 with Select

use of com.activeandroid.query.Select in project xDrip by NightscoutFoundation.

the class UploaderQueue method getCount.

private static int getCount(String where) {
    try {
        final String query = new Select("COUNT(*) as total").from(UploaderQueue.class).toSql();
        final Cursor resultCursor = Cache.openDatabase().rawQuery(query + where, null);
        if (resultCursor.moveToNext()) {
            final int total = resultCursor.getInt(0);
            resultCursor.close();
            return total;
        } else {
            return 0;
        }
    } catch (Exception e) {
        Log.d(TAG, "Got exception getting count: " + e);
        return 0;
    }
}
Also used : Select(com.activeandroid.query.Select) Cursor(android.database.Cursor) JSONException(org.json.JSONException)

Example 27 with Select

use of com.activeandroid.query.Select in project xDrip by NightscoutFoundation.

the class UploaderQueue method getClasses.

private static List<String> getClasses() {
    fixUpTable();
    final ArrayList<String> results = new ArrayList<>();
    final String query = new Select("distinct otype as otypes").from(UploaderQueue.class).toSql();
    final Cursor resultCursor = Cache.openDatabase().rawQuery(query, null);
    while (resultCursor.moveToNext()) {
        results.add(resultCursor.getString(0));
    }
    resultCursor.close();
    return results;
}
Also used : ArrayList(java.util.ArrayList) Select(com.activeandroid.query.Select) Cursor(android.database.Cursor)

Example 28 with Select

use of com.activeandroid.query.Select in project xDrip by NightscoutFoundation.

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)

Example 29 with Select

use of com.activeandroid.query.Select in project xDrip by NightscoutFoundation.

the class Treatments method latestForGraph.

public static List<Treatments> latestForGraph(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("timestamp >= ? and timestamp <= ?", df.format(startTime), df.format(endTime)).orderBy("timestamp desc").limit(number).execute();
}
Also used : DecimalFormat(java.text.DecimalFormat) Select(com.activeandroid.query.Select)

Example 30 with Select

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

the class UserError method bySeverity.

public static List<UserError> bySeverity(Integer[] levels) {
    String levelsString = " ";
    for (int level : levels) {
        levelsString += level + ",";
    }
    Log.d("UserError", "severity in (" + levelsString.substring(0, levelsString.length() - 1) + ")");
    return new Select().from(UserError.class).where("severity in (" + levelsString.substring(0, levelsString.length() - 1) + ")").orderBy("timestamp desc").limit(// too many data can kill akp
    10000).execute();
}
Also used : 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