Java Code Examples for com.squareup.sqlbrite.SqlBrite#wrapDatabaseHelper()

The following examples show how to use com.squareup.sqlbrite.SqlBrite#wrapDatabaseHelper() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StorageModule.java    From TodoFluxArchitecture with Apache License 2.0 5 votes vote down vote up
/**
 * 提供BriteDatabase注入.
 *
 * @return BriteDatabase
 */
@Provides
BriteDatabase briteDatabase() {
    SqlBrite sqlBrite = SqlBrite.create(message -> LogTool.debug("Database", message));

    SQLiteOpenHelper sqLiteOpenHelper = new DatabaseOpenHelper(application, userId);
    BriteDatabase db = sqlBrite.wrapDatabaseHelper(sqLiteOpenHelper);
    db.setLoggingEnabled(BuildConfig.DEBUG);
    return db;
}
 
Example 2
Source File: ElifutDataStore.java    From android with Apache License 2.0 5 votes vote down vote up
public ElifutDataStore(Context context, SqlBrite sqlBrite,
    List<Persistable.Converter<?>> converters) {
  super(context, "ElifutDB", null, 1);
  // TODO: Change to io() or computation() scheduler but needs to fix failing test
  db = sqlBrite.wrapDatabaseHelper(this, AndroidSchedulers.mainThread());
  for (Persistable.Converter<?> converter : converters) {
    converterMap.put(converter.targetType(), converter);
  }
}
 
Example 3
Source File: DatabaseModule.java    From droidconat-2016 with Apache License 2.0 4 votes vote down vote up
@Provides @Singleton BriteDatabase provideBriteDatabase(SqlBrite sqlBrite, SQLiteOpenHelper helper) {
    return sqlBrite.wrapDatabaseHelper(helper, Schedulers.immediate());
}
 
Example 4
Source File: ApplicationModule.java    From FriendlyDemo with Apache License 2.0 4 votes vote down vote up
@Provides
@NonNull
@Singleton
public BriteDatabase provideDatabase(SqlBrite sqlBrite, Database helper) {
    return sqlBrite.wrapDatabaseHelper(helper, Schedulers.io());
}
 
Example 5
Source File: DaoManager.java    From sqlbrite-dao with Apache License 2.0 4 votes vote down vote up
private DaoManager(Builder builder) {

    if (builder.name == null) {
      throw new IllegalArgumentException(
          "Database name not set. Use Builder.databaseName() to specify a database name");
    }

    if (builder.version == -1) {
      throw new IllegalArgumentException(
          "Database version not set. Use Builder.version() to specify the database version");
    }

    if (builder.daos.isEmpty()) {
      throw new IllegalArgumentException(
          "No DAO added. Use Builder.add() to register at least one DAO");
    }

    this.name = builder.name;
    this.version = builder.version;
    this.createdListener = builder.createdListener;
    this.upgradedListener = builder.upgradedListener;
    this.daos = builder.daos;

    OpenHelper openHelper;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
      openHelper = new OpenHelper(builder.context, name, builder.cursorFactory, version,
          builder.errorHandler, builder.foreignKeyConstraints);
    } else {
      openHelper = new OpenHelperApi16(builder.context, name, builder.cursorFactory, version,
          builder.errorHandler, builder.foreignKeyConstraints);
    }

    SqlBrite brite;
    if (builder.logger != null) {
      brite = SqlBrite.create(builder.logger);
    } else {
      brite = SqlBrite.create();
    }

    db = brite.wrapDatabaseHelper(openHelper,
        builder.scheduler == null ? Schedulers.io() : builder.scheduler);
    db.setLoggingEnabled(builder.logging);

    for (Dao dao : builder.daos) {
      dao.setSqlBriteDb(db);
    }
  }
 
Example 6
Source File: PlaceModel.java    From Fishing with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onAppCreate(Context ctx) {
    SqlBrite mSqlBrite = SqlBrite.create(s -> JUtils.Log("DB",s));
    mDbBrite = mSqlBrite.wrapDatabaseHelper(new DBHelper(ctx));
}