本文整理汇总了Java中hu.akarnokd.rxjava.interop.RxJavaInterop类的典型用法代码示例。如果您正苦于以下问题:Java RxJavaInterop类的具体用法?Java RxJavaInterop怎么用?Java RxJavaInterop使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RxJavaInterop类属于hu.akarnokd.rxjava.interop包,在下文中一共展示了RxJavaInterop类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Override
public void handle(RoutingContext routingContext) {
Long albumId = PathUtil.parseLongParam(routingContext.pathParam("albumId"));
if (albumId == null) {
routingContext.next();
return;
}
com.couchbase.client.java.document.json.JsonArray params = com.couchbase.client.java.document.json.JsonArray.from(albumId);
ParametrizedQuery parametrizedQuery = Query.parametrized(findRecentCommentsByAlbum, params);
Observable<AsyncQueryRow> rowsObservable = albumCommentsBucket.query(parametrizedQuery)
.flatMap(AsyncQueryResult::rows);
RxJavaInterop.toV2Flowable(rowsObservable)
.observeOn(RxHelper.scheduler(routingContext.vertx().getOrCreateContext()))
.limit(5)
.collect(JsonArray::new, (jsonArray, row) -> jsonArray.add(new JsonObject(row.value().toMap())))
.flatMap(data -> {
routingContext.put("comments", data);
return templateEngine.rxRender(routingContext, "templates/partials/album_comments");
}).subscribe(routingContext.response()::end, routingContext::fail);
}
示例2: decodeQrCode
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
private void decodeQrCode() {
if (mBigImageView.getCurrentImageFile() == null) {
return;
}
disposeQrCodeDecode();
mQrCodeDecode = RxJavaInterop
.toV2Observable(RxQrCode.scanFromPicture(
mBigImageView.getCurrentImageFile().getAbsolutePath()))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<Result>() {
@Override
public void accept(Result result) throws Exception {
Toast.makeText(LongImageActivity.this,
"Found " + result.getText(),
Toast.LENGTH_SHORT).show();
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
Toast.makeText(LongImageActivity.this,
"Not found",
Toast.LENGTH_SHORT).show();
}
});
}
示例3: handle
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Override
public void handle(RoutingContext rc) {
Long albumId = PathUtil.parseLongParam(rc.pathParam("albumId"));
if (albumId == null) {
rc.next();
return;
}
User user = rc.user();
if (user == null) {
rc.response().setStatusCode(HTTP_UNAUTHORIZED).end();
return;
}
String comment = rc.getBodyAsString();
if (comment == null || comment.isEmpty()) {
rc.response().setStatusCode(HTTP_BAD_REQUEST).end();
return;
}
long timestamp = System.currentTimeMillis();
JsonObject content = new JsonObject()
.put("albumId", albumId)
.put("username", user.principal().getValue("username"))
.put("timestamp", timestamp)
.put("comment", comment);
JsonDocument document = JsonDocument.create("comment::" + timestamp, com.couchbase.client.java.document.json.JsonObject.from(content.getMap()));
Vertx vertx = rc.vertx();
Observable<JsonDocument> documentObservable = albumCommentsBucket.upsert(document);
RxJavaInterop.toV2Single(documentObservable.toSingle())
.observeOn(RxHelper.scheduler(vertx.getOrCreateContext()))
.doOnSuccess(doc -> vertx.setTimer(1000, v -> {
String address = "album." + albumId + ".comments.new";
vertx.eventBus().<JsonObject>publish(address, content);
}))
.subscribe(doc -> rc.response().end(), rc::fail);
}
示例4: setupBucket
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
private Completable setupBucket() {
SimpleQuery findPrimaryIndex = Query.simple(couchbaseQueries.getProperty("findAlbumCommentsPrimaryIndex"));
SimpleQuery createPrimaryIndex = Query.simple(couchbaseQueries.getProperty("createAlbumCommentsPrimaryIndex"));
rx.Completable setupCompletable = albumCommentsBucket.get().query(findPrimaryIndex)
.switchIfEmpty(albumCommentsBucket.get().query(createPrimaryIndex))
.toCompletable();
return RxJavaInterop.toV2Completable(setupCompletable)
.observeOn(RxHelper.scheduler(vertx.getOrCreateContext()));
}
示例5: selectAllAsNotifiedObservable
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
public <T> Observable<List<T>> selectAllAsNotifiedObservable(BaseEntity<T> entity,
String order) {
String sql = createSelectAllQuery(entity, order);
return RxJavaInterop.toV2Observable(
briteDatabase.createQuery(entity.getTableName(), sql)
.mapToList(entity::fromCursor));
}
示例6: forFlowable
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Override public <U> FlowableTransformer<U, U> forFlowable() {
return new FlowableTransformer<U, U>() {
@Override public Publisher<U> apply(Flowable<U> source) {
rx.Observable<U> rxObservable = RxJavaInterop.toV1Observable(source.toObservable(), strategy);
rx.Observable<T> observableBound = rxObservable.compose(
(rx.Observable.Transformer<? super U, ? extends T>) rxTransformerBound);
return (Publisher<U>) RxJavaInterop.toV2Observable(observableBound).toFlowable(strategy);
}
};
}
示例7: forSingle
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Override public <U> SingleTransformer<U, U> forSingle() {
return new SingleTransformer<U, U>() {
@Override public SingleSource<U> apply(io.reactivex.Single<U> source) {
rx.Single<U> rxSourceSingle =
RxJavaInterop.toV1Single(source);
rx.Single<T> rxBoundSingle = rxSourceSingle
.compose((Single.Transformer<? super U, ? extends T>) rxSingleTransformer);
return (io.reactivex.Single<U>) RxJavaInterop.toV2Single(rxBoundSingle);
}
};
}
示例8: bindActivity
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@NonNull
@CheckResult
public static <T> LifecycleTransformer2x<T> bindActivity(
@NonNull final Observable<ActivityEvent> lifecycle,
@NonNull final BackpressureStrategy strategy) {
LifecycleTransformer<T> rxTransformer =
RxLifecycleAndroid.bindActivity(RxJavaInterop.toV1Observable(lifecycle, strategy));
return new LifecycleTransformer2xBehaviour<>(rxTransformer, rxTransformer.forSingle(),
strategy);
}
示例9: bindFragment
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@NonNull
@CheckResult
public static <T> LifecycleTransformer2x<T> bindFragment(
@NonNull final Observable<FragmentEvent> lifecycle,
@NonNull final BackpressureStrategy strategy) {
LifecycleTransformer<T> rxTransformer =
RxLifecycleAndroid.bindFragment(RxJavaInterop.toV1Observable(lifecycle, strategy));
return new LifecycleTransformer2xBehaviour<>(rxTransformer, rxTransformer.forSingle(),
strategy);
}
示例10: bindPreference
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
void bindPreference(final CheckBox checkBox, Preference<Boolean> preference) {
// Bind the preference to the checkbox.
disposables.add(preference.asObservable()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(checkBox::setChecked));
// Bind the checkbox to the preference.
disposables.add(RxJavaInterop.toV2Observable(RxCompoundButton.checkedChanges(checkBox))
.skip(1) // First emission is the original state.
.subscribe(preference.asConsumer()));
}
示例11: singleAsObservable
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
public Observable<E> singleAsObservable() {
rx.Observable<E> o = briteResolver.createQuery(baseUri,
projection,
selection.toString(),
getSelectionArgs(),
sortOrderWithLimit(" LIMIT 1 "), true)
.mapToOne(cursor -> EntityMapper.forEntity(clazz).fromCursor(cursor))
.throttleFirst(THROTTLE_BATCH, TimeUnit.MILLISECONDS);
return RxJavaInterop.toV2Observable(o);
}
示例12: onStartClicks
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Override
public Observable<Object> onStartClicks() {
return RxJavaInterop.toV2Observable(RxView.clicks(btnStart).map(aVoid -> new Object()));
}
示例13: onStopClicks
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Override
public Observable<Object> onStopClicks() {
return RxJavaInterop.toV2Observable(RxView.clicks(btnStop).map(aVoid -> new Object()));
}
示例14: startAsV1Observable
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Deprecated
public rx.Observable<Integer> startAsV1Observable() {
return RxJavaInterop.toV1Observable(start());
}
示例15: phoneNumberChanges
import hu.akarnokd.rxjava.interop.RxJavaInterop; //导入依赖的package包/类
@Override
public Flowable<CharSequence> phoneNumberChanges() {
return RxJavaInterop.toV2Flowable(RxTextView.textChanges(mEtPhone));
}