Search in sources :

Example 1 with BriteDatabase

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

the class WhitelistHelper method addToWhitelist.

public static void addToWhitelist(List<String> paths) {
    BriteDatabase db = DataManager.getInstance().getWhitelistDatabase();
    BriteDatabase.Transaction transaction = db.newTransaction();
    try {
        Stream.of(paths).map(path -> {
            ContentValues contentValues = new ContentValues();
            contentValues.put(WhitelistDbOpenHelper.COLUMN_FOLDER, path);
            return contentValues;
        }).forEach(contentValues -> db.insert(WhitelistDbOpenHelper.TABLE_FOLDERS, contentValues));
        transaction.markSuccessful();
    } finally {
        transaction.end();
    }
}
Also used : List(java.util.List) Stream(com.annimon.stream.Stream) WhitelistFolder(com.simplecity.amp_library.model.WhitelistFolder) BriteDatabase(com.squareup.sqlbrite.BriteDatabase) DataManager(com.simplecity.amp_library.utils.DataManager) ContentValues(android.content.ContentValues) Observable(rx.Observable) ContentValues(android.content.ContentValues) BriteDatabase(com.squareup.sqlbrite.BriteDatabase)

Example 2 with BriteDatabase

use of com.squareup.sqlbrite.BriteDatabase in project sqlbrite by square.

the class DbModule method provideDatabase.

@Provides
@Singleton
BriteDatabase provideDatabase(SqlBrite sqlBrite, SQLiteOpenHelper helper) {
    BriteDatabase db = sqlBrite.wrapDatabaseHelper(helper, Schedulers.io());
    db.setLoggingEnabled(true);
    return db;
}
Also used : BriteDatabase(com.squareup.sqlbrite.BriteDatabase) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 3 with BriteDatabase

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

the class BlacklistHelper method addToBlacklist.

public static void addToBlacklist(List<Song> songs) {
    BriteDatabase db = DataManager.getInstance().getBlacklistDatabase();
    BriteDatabase.Transaction transaction = db.newTransaction();
    try {
        Stream.of(songs).map(song -> {
            ContentValues contentValues = new ContentValues();
            contentValues.put(BlacklistDbOpenHelper.COLUMN_SONG_ID, song.id);
            return contentValues;
        }).forEach(contentValues -> db.insert(BlacklistDbOpenHelper.TABLE_SONGS, contentValues));
        transaction.markSuccessful();
    } finally {
        transaction.end();
    }
}
Also used : BlacklistedSong(com.simplecity.amp_library.model.BlacklistedSong) Song(com.simplecity.amp_library.model.Song) List(java.util.List) Stream(com.annimon.stream.Stream) BriteDatabase(com.squareup.sqlbrite.BriteDatabase) DataManager(com.simplecity.amp_library.utils.DataManager) ContentValues(android.content.ContentValues) Observable(rx.Observable) ContentValues(android.content.ContentValues) BriteDatabase(com.squareup.sqlbrite.BriteDatabase)

Aggregations

BriteDatabase (com.squareup.sqlbrite.BriteDatabase)3 ContentValues (android.content.ContentValues)2 Stream (com.annimon.stream.Stream)2 DataManager (com.simplecity.amp_library.utils.DataManager)2 List (java.util.List)2 Observable (rx.Observable)2 BlacklistedSong (com.simplecity.amp_library.model.BlacklistedSong)1 Song (com.simplecity.amp_library.model.Song)1 WhitelistFolder (com.simplecity.amp_library.model.WhitelistFolder)1 Provides (dagger.Provides)1 Singleton (javax.inject.Singleton)1