本文整理匯總了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;
}
});
}
示例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;
}
});
}
示例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);
}
示例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();
}
}
示例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();
});
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}