Search in sources :

Example 1 with BriteDatabase

use of com.squareup.sqlbrite2.BriteDatabase in project Shuttle by timusus.

the class InclExclHelper method addToInclExcl.

public static void addToInclExcl(List<InclExclItem> inclExclItems) {
    BriteDatabase db = DataManager.getInstance().getInclExclDatabase();
    BriteDatabase.Transaction transaction = db.newTransaction();
    try {
        Stream.of(inclExclItems).map(inclExclItem -> {
            ContentValues contentValues = new ContentValues(2);
            contentValues.put(InclExclDbOpenHelper.COLUMN_PATH, inclExclItem.path);
            contentValues.put(InclExclDbOpenHelper.COLUMN_TYPE, inclExclItem.type);
            return contentValues;
        }).forEach(contentValues -> db.insert(InclExclDbOpenHelper.TABLE_NAME, contentValues));
        transaction.markSuccessful();
    } finally {
        transaction.end();
    }
}
Also used : Song(com.simplecity.amp_library.model.Song) List(java.util.List) BriteDatabase(com.squareup.sqlbrite2.BriteDatabase) Stream(com.annimon.stream.Stream) DataManager(com.simplecity.amp_library.utils.DataManager) ContentValues(android.content.ContentValues) InclExclItem(com.simplecity.amp_library.model.InclExclItem) ContentValues(android.content.ContentValues) BriteDatabase(com.squareup.sqlbrite2.BriteDatabase)

Aggregations

ContentValues (android.content.ContentValues)1 Stream (com.annimon.stream.Stream)1 InclExclItem (com.simplecity.amp_library.model.InclExclItem)1 Song (com.simplecity.amp_library.model.Song)1 DataManager (com.simplecity.amp_library.utils.DataManager)1 BriteDatabase (com.squareup.sqlbrite2.BriteDatabase)1 List (java.util.List)1