Search in sources :

Example 46 with Select

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

the class Reminder method getNextActiveReminder.

public static Reminder getNextActiveReminder() {
    fixUpTable(schema);
    final long now = JoH.tsl();
    final Reminder reminder = new Select().from(Reminder.class).where("enabled = ?", true).where("next_due < ?", now).where("snoozed_till < ?", now).where("last_fired < (? - (600000 * alerted_times))", now).orderBy("enabled desc, priority desc, next_due asc").executeSingle();
    return reminder;
}
Also used : Select(com.activeandroid.query.Select)

Example 47 with Select

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

the class LibreBlock method getForTimestamp.

public static LibreBlock getForTimestamp(long timestamp) {
    final double margin = (3 * 1000);
    final DecimalFormat df = new DecimalFormat("#");
    df.setMaximumFractionDigits(1);
    return new Select().from(LibreBlock.class).where("timestamp >= " + df.format(timestamp - margin)).where("timestamp <= " + df.format(timestamp + margin)).executeSingle();
}
Also used : DecimalFormat(java.text.DecimalFormat) Select(com.activeandroid.query.Select)

Example 48 with Select

use of com.activeandroid.query.Select in project ActiveAndroid by pardom.

the class CountTest method testCountWhereClauseSql.

/**
 * Should be a count with the specified where-clause.
 */
public void testCountWhereClauseSql() {
    final String expected = "SELECT COUNT(*) FROM MockModel WHERE intField = ?";
    String actual = new Select().from(MockModel.class).where("intField = ?", 1).toCountSql();
    assertEquals(expected, actual);
}
Also used : Select(com.activeandroid.query.Select)

Example 49 with Select

use of com.activeandroid.query.Select in project ActiveAndroid by pardom.

the class CountTest method testCountTable.

/**
 * Should return the same count as there are entries in the result set/table.
 */
public void testCountTable() {
    cleanTable();
    populateTable();
    From from = new Select().from(MockModel.class);
    final List<MockModel> list = from.execute();
    final int count = from.count();
    assertEquals(3, count);
    assertEquals(list.size(), count);
}
Also used : MockModel(com.activeandroid.test.MockModel) Select(com.activeandroid.query.Select) From(com.activeandroid.query.From)

Example 50 with Select

use of com.activeandroid.query.Select in project ActiveAndroid by pardom.

the class CountTest method testCountOrderBy.

/**
 * Should not change the result if order by is used.
 */
public void testCountOrderBy() {
    cleanTable();
    populateTable();
    From from = new Select().from(MockModel.class).where("intField = ?", 1).orderBy("intField ASC");
    final List<MockModel> list = from.execute();
    final int count = from.count();
    assertEquals(2, count);
    assertEquals(list.size(), count);
}
Also used : MockModel(com.activeandroid.test.MockModel) Select(com.activeandroid.query.Select) From(com.activeandroid.query.From)

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