本文整理汇总了Java中ru.arturvasilov.sqlite.rx.RxSQLite类的典型用法代码示例。如果您正苦于以下问题:Java RxSQLite类的具体用法?Java RxSQLite怎么用?Java RxSQLite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RxSQLite类属于ru.arturvasilov.sqlite.rx包,在下文中一共展示了RxSQLite类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onTableChanged
import ru.arturvasilov.sqlite.rx.RxSQLite; //导入依赖的package包/类
@Override
public void onTableChanged() {
Where where = Where.create().equalTo(RequestTable.REQUEST, NetworkRequest.CITY_WEATHER);
RxSQLite.get().querySingle(RequestTable.TABLE, where)
.compose(RxSchedulers.async())
.flatMap(request -> {
if (request.getStatus() == RequestStatus.IN_PROGRESS) {
mLoadingView.showLoadingIndicator();
return Observable.empty();
} else if (request.getStatus() == RequestStatus.ERROR) {
return Observable.error(new IOException(request.getError()));
}
return RxSQLite.get().querySingle(CityTable.TABLE).compose(RxSchedulers.async());
})
.subscribe(city -> {
mCity = city;
showWeather();
mLoadingView.hideLoadingIndicator();
}, throwable -> {
showError();
mLoadingView.hideLoadingIndicator();
});
}
示例2: registerObserver
import ru.arturvasilov.sqlite.rx.RxSQLite; //导入依赖的package包/类
public <T> void registerObserver(@NonNull Context context, @NonNull final Table<T> table,
@NonNull final ContentTableObserver<T> observer, @NonNull final Where where) {
ContentObserver contentObserver = new DatabaseObserver() {
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
RxSQLite.get().query(table, where)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<List<T>>() {
@Override
public void accept(List<T> list) throws Exception {
observer.onTableChanged(list);
}
});
}
};
context.getContentResolver().registerContentObserver(table.getUri(), false, contentObserver);
mObservers.add(new Pair<Object, ContentObserver>(observer, contentObserver));
}
示例3: getCurrentUser
import ru.arturvasilov.sqlite.rx.RxSQLite; //导入依赖的package包/类
@NonNull
public Observable<User> getCurrentUser() {
return RepositoryProvider.provideKeyValueStorage().getCurrentUserId()
.take(1)
.filter(id -> id > 0)
.map(String::valueOf)
.flatMap(id -> RxSQLite.get().queryObject(UserTable.TABLE, Where.create()
.where(UserTable.USER_ID + "=?")
.whereArgs(new String[]{id})))
.compose(RxSchedulers.async());
}
示例4: questions
import ru.arturvasilov.sqlite.rx.RxSQLite; //导入依赖的package包/类
@NonNull
public Observable<List<Question>> questions(@NonNull String tag) {
return RxSQLite.get().query(QuestionTable.TABLE, Where.create()
.where(QuestionTable.TAG + "=?")
.whereArgs(new String[]{tag}))
.compose(RxSchedulers.async());
}
示例5: cachedRepositories
import ru.arturvasilov.sqlite.rx.RxSQLite; //导入依赖的package包/类
@NonNull
@Override
public Observable<List<Repository>> cachedRepositories() {
return RxSQLite.get().query(RepositoryTable.TABLE);
}
示例6: tags
import ru.arturvasilov.sqlite.rx.RxSQLite; //导入依赖的package包/类
@NonNull
public Observable<List<String>> tags() {
return RxSQLite.get().query(TagTable.TABLE, Where.create())
.compose(RxSchedulers.async());
}