當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。