当前位置: 首页>>代码示例>>Java>>正文


Java SqlBrite类代码示例

本文整理汇总了Java中com.squareup.sqlbrite.SqlBrite的典型用法代码示例。如果您正苦于以下问题:Java SqlBrite类的具体用法?Java SqlBrite怎么用?Java SqlBrite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SqlBrite类属于com.squareup.sqlbrite包,在下文中一共展示了SqlBrite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLocation

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
public Observable<PointOfInterest> getLocation(final String id) {
    return mBriteDb.createQuery(Db.PointOfInterestTable.TABLE_NAME,
            "SELECT * FROM " + Db.PointOfInterestTable.TABLE_NAME +
                    " WHERE " + Db.PointOfInterestTable.COLUMN_ID + "=?", id)
            .map(new Func1<SqlBrite.Query, PointOfInterest>() {
                @Override
                public PointOfInterest call(SqlBrite.Query query) {
                    PointOfInterest result = null;
                    Cursor cursor = query.run();
                    if (cursor.moveToFirst()) {
                        PointOfInterest pointOfInterest =
                                Db.PointOfInterestTable.parseCursor(cursor);
                        if (pointOfInterest.id.equals(id)) result = pointOfInterest;
                    }
                    cursor.close();
                    return result;
                }
            });
}
 
开发者ID:sathishmscict,项目名称:Pickr,代码行数:20,代码来源:DatabaseHelper.java

示例2: getLocations

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
public Observable<List<PointOfInterest>> getLocations() {
    return mBriteDb.createQuery(Db.PointOfInterestTable.TABLE_NAME,
            "SELECT * FROM " + Db.PointOfInterestTable.TABLE_NAME)
            .map(new Func1<SqlBrite.Query, List<PointOfInterest>>() {
                @Override
                public List<PointOfInterest> call(SqlBrite.Query query) {
                    Cursor cursor = query.run();
                    List<PointOfInterest> result = new ArrayList<>();
                    while (cursor.moveToNext()) {
                        result.add(Db.PointOfInterestTable.parseCursor(cursor));
                    }
                    cursor.close();
                    return result;
                }
            });
}
 
开发者ID:sathishmscict,项目名称:Pickr,代码行数:17,代码来源:DatabaseHelper.java

示例3: Repository

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
public Repository(Context context) {
    SchedulerProvider schedulerProvider = DefaultSchedulerProvider.getInstance();
    DbHelper openHelper = new DbHelper(context);
    SqlBrite sqlBrite = new SqlBrite.Builder().build();
    // TODO: switch to the rxjava2 scheduler when new sqlbrite will be released
    BriteDatabase briteDatabase = sqlBrite.wrapDatabaseHelper(openHelper, Schedulers.io());

    if (BuildConfig.DEBUG) {
        briteDatabase.setLoggingEnabled(true);
    }

    briteDatabaseHelper = new BriteDatabaseHelper(briteDatabase);

    Dependencies dependencies = new Dependencies(context, this, briteDatabaseHelper,
            schedulerProvider);

    artistRepository = new ArtistRepository(dependencies);
    locationRepository = new LocationRepository(dependencies);
    concertRepository = new ConcertRepository(dependencies);
    syncStateRepository = new SyncStateRepository(dependencies);
    syncRepository = new SyncRepository(dependencies);
}
 
开发者ID:andreybgm,项目名称:gigreminder,代码行数:23,代码来源:Repository.java

示例4: call

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
@Override public List<Vocabulary> call(SqlBrite.Query query) {
  Cursor cursor = query.run();
  try {
    List<Vocabulary> values = new ArrayList<>(cursor.getCount());

    while (cursor.moveToNext()) {
      values.add(new AutoParcel_Vocabulary(
          DbUtils.getLong(cursor, ID),
          DbUtils.getString(cursor, ORIGINAL),
          DbUtils.getString(cursor, TRANSLATED),
          DbUtils.getString(cursor, LANG_ORIGINAL),
          DbUtils.getString(cursor, LANG_TRANSLATED)
      ));
    }
    return values;
  } finally {
    cursor.close();
  }
}
 
开发者ID:GerardPaligot,项目名称:LearnIt,代码行数:20,代码来源:Vocabulary.java

示例5: LocalMessageStore

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
public LocalMessageStore(Context context, SqlBrite brite) {
    this.brite = brite;
    this.context = context;

    // XXX Oh yes, oh yeah, OH YES, OH YEAH!
    this.subscription = brite.createQuery(LocalMessage.TABLE,
            "SELECT COUNT(" + LocalMessage.ID + ") " +
                    "FROM " + LocalMessage.TABLE + " " +
                    "WHERE " + LocalMessage.STATUS + " = ?",
            LocalMessage.valueOf(LocalMessage.Status.QUEUE))
            .map(SqlBrite.Query::run)
            .subscribeOn(Schedulers.io())
            .observeOn(Schedulers.io())
            .subscribe(cursor -> {
                cursor.moveToFirst();
                long count = cursor.getLong(0);
                if (count > 0)
                    startService();
            });
}
 
开发者ID:labhackercd,项目名称:edm,代码行数:21,代码来源:LocalMessageStore.java

示例6: provideSqlBrite

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
@Provides
@Singleton
SqlBrite provideSqlBrite(SQLiteOpenHelper openHelper) {
    SqlBrite db = SqlBrite.create(openHelper);

    if (BuildConfig.DEBUG) {
        db.setLogger(new SqlBrite.Logger() {
            @Override
            public void log(String message) {
                Timber.tag("Database").v(message);
            }
        });
        db.setLoggingEnabled(true);
    }

    return db;
}
 
开发者ID:thanksmister,项目名称:BitcoinBlue,代码行数:18,代码来源:DbModule.java

示例7: provideDatabase

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
@Provides
@Singleton
BriteDatabase provideDatabase(SqlBrite sqlBrite, SQLiteOpenHelper helper) {
    BriteDatabase db = sqlBrite.wrapDatabaseHelper(helper, Schedulers.io());
    db.setLoggingEnabled(true);
    return db;
}
 
开发者ID:geralt-encore,项目名称:Delightful-SQLBrite,代码行数:8,代码来源:DbModule.java

示例8: LocalAccountsDataSource

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
@Inject
public LocalAccountsDataSource(@NonNull Context context, SchedulerProvider schedulerProvider) {
    checkNotNull(context);
    AccountsDbHelper accountsDbHelper = new AccountsDbHelper(context);
    SqlBrite sqlBrite = SqlBrite.create();
    this.accountsDbHelper = sqlBrite.wrapDatabaseHelper(accountsDbHelper, schedulerProvider.io());

    accountMapperFunction = this::getAccount;
}
 
开发者ID:przemyslaw-holownia,项目名称:financial-manager,代码行数:10,代码来源:LocalAccountsDataSource.java

示例9: all

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
public Observable<List<Permission>> all(BriteDatabase db) {
  CursorToListMapper<Permission> cursorToList =
      new CursorToListMapper<>(Permission.FACTORY.selectAllMapper());
  SqlDelightStatement selectAll = Permission.FACTORY.selectAll();

  return db.createQuery(selectAll.tables, selectAll.statement)
      .map(SqlBrite.Query::run)
      .map(cursorToList);
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:10,代码来源:PermissionRepository.java

示例10: byApp

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
public Observable<List<Permission>> byApp(BriteDatabase db, long appId, boolean isGranted) {
  SqlDelightStatement selectByApp = Permission.FACTORY.selectByApp(appId, isGranted);
  CursorToListMapper<Permission> cursorToList =
      new CursorToListMapper<>(Permission.FACTORY.selectByAppMapper());

  return db.createQuery(selectByApp.tables, selectByApp.statement, selectByApp.args)
      .map(SqlBrite.Query::run)
      .map(cursorToList);
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:10,代码来源:PermissionRepository.java

示例11: byAppAndLibrary

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
public Observable<List<Permission>> byAppAndLibrary(BriteDatabase db, long appId,
    String libraryId) {
  SqlDelightStatement selectByAppAndLibrary =
      Permission.FACTORY.selectByAppAndLibrary(appId, libraryId);
  CursorToListMapper<Permission> cursorToList =
      new CursorToListMapper<>(Permission.FACTORY.selectByAppAndLibraryMapper());

  return db.createQuery(selectByAppAndLibrary.tables, selectByAppAndLibrary.statement,
      selectByAppAndLibrary.args)
      .map(SqlBrite.Query::run)
      .map(cursorToList);
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:13,代码来源:PermissionRepository.java

示例12: all

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
public Observable<List<PermissionGroup>> all(BriteDatabase db) {
  CursorToListMapper<PermissionGroup> cursorToList =
      new CursorToListMapper<>(PermissionGroup.FACTORY.selectAllMapper());
  SqlDelightStatement selectAll = PermissionGroup.FACTORY.selectAll();

  return db.createQuery(selectAll.tables, selectAll.statement)
      .map(SqlBrite.Query::run)
      .map(cursorToList);
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:10,代码来源:PermissionGroupRepository.java

示例13: byId

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
public Observable<List<PermissionGroup>> byId(BriteDatabase db, String id) {
  SqlDelightStatement selectById = PermissionGroup.FACTORY.selectById(id);
  CursorToListMapper<PermissionGroup> cursorToList =
      new CursorToListMapper<>(PermissionGroup.FACTORY.selectByIdMapper());

  return db.createQuery(selectById.tables, selectById.statement, selectById.args)
      .map(SqlBrite.Query::run)
      .map(cursorToList);
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:10,代码来源:PermissionGroupRepository.java

示例14: all

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
public Observable<List<Version>> all(BriteDatabase db) {
  CursorToListMapper<Version> cursorToList =
      new CursorToListMapper<>(Version.FACTORY.selectAllMapper());
  SqlDelightStatement selectAll = Version.FACTORY.selectAll();

  return db.createQuery(selectAll.tables, selectAll.statement)
      .map(SqlBrite.Query::run)
      .map(cursorToList);
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:10,代码来源:VersionRepository.java

示例15: byAppId

import com.squareup.sqlbrite.SqlBrite; //导入依赖的package包/类
public Observable<List<Version>> byAppId(BriteDatabase db, long appId) {
  SqlDelightStatement selectByApp = Version.FACTORY.selectByApp(appId);
  CursorToListMapper<Version> cursorToList =
      new CursorToListMapper<>(Version.FACTORY.selectByAppMapper());

  return db.createQuery(selectByApp.tables, selectByApp.statement, selectByApp.args)
      .map(SqlBrite.Query::run)
      .map(cursorToList);
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:10,代码来源:VersionRepository.java


注:本文中的com.squareup.sqlbrite.SqlBrite类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。