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

The following examples show how to use com.squareup.sqlbrite.SqlBrite#create() . 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: SqlbriteDemoActivity.java    From RxJavaExplained with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.list_of_kittens_layout);
  listOfKittens = (RecyclerView) findViewById(R.id.list_of_kittens);
  floatingActionButton = (FloatingActionButton) findViewById(R.id.fab);
  floatingActionButton.setOnClickListener(this::addRandomKitten);
  sqlBrite = SqlBrite.create();
  kittenAdapter = new KittenAdapter(this);
  listOfKittens.setLayoutManager(new LinearLayoutManager(this));
  listOfKittens.setAdapter(kittenAdapter);
}
 
Example 3
Source File: DatabaseModule.java    From droidconat-2016 with Apache License 2.0 4 votes vote down vote up
@Provides @Singleton SqlBrite provideSqlBrite() {
    return SqlBrite.create(Timber.tag(TAG)::v);
}
 
Example 4
Source File: ApplicationModule.java    From FriendlyDemo with Apache License 2.0 4 votes vote down vote up
@Provides
@NonNull
@Singleton
public SqlBrite provideSqlBrite() {
    return SqlBrite.create(message -> Timber.tag("Database").v(message));
}
 
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));
}
 
Example 7
Source File: DataModule.java    From android with Apache License 2.0 4 votes vote down vote up
@Provides @Singleton ElifutDataStore provideDataStore(List<Persistable.Converter<?>> converters) {
  return new ElifutDataStore(context, SqlBrite.create(), converters);
}