Java Code Examples for hu.akarnokd.rxjava.interop.RxJavaInterop#toV2Observable()

The following examples show how to use hu.akarnokd.rxjava.interop.RxJavaInterop#toV2Observable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PurchasesService.java    From Building-Professional-Android-Applications with MIT License 6 votes vote down vote up
public Observable<Boolean> monitorPurchases(Context context) {
    return RxJavaInterop.toV2Observable(
            rx.Observable.concat(
                    rx.Observable.just(false),
                    ReactiveBilling.getInstance(context)
                            .getPurchases(PurchaseType.PRODUCT, null)
                            .subscribeOn(Schedulers.io())
                            .observeOn(AndroidSchedulers.mainThread())
                            .map(GetPurchasesResponse::getList)
                            .flatMap(rx.Observable::from)
                            .map(GetPurchasesResponse.PurchaseResponse::getProductId)
                            .filter(item -> PREMIUM_SKU_ID.equals(item))
                            .map(item -> true)
                            .firstOrDefault(false),
                    ReactiveBilling.getInstance(context).purchaseFlow()
                            .doOnNext(this::recordPurchase)
                            .map(PurchaseResponse::isSuccess)
            )
    );
}
 
Example 2
Source File: PurchasesService.java    From Building-Professional-Android-Applications with MIT License 6 votes vote down vote up
public Observable<Boolean> monitorPurchases(Context context) {
    return RxJavaInterop.toV2Observable(
            rx.Observable.concat(
                    rx.Observable.just(false),
                    ReactiveBilling.getInstance(context)
                            .getPurchases(PurchaseType.PRODUCT, null)
                            .subscribeOn(Schedulers.io())
                            .observeOn(AndroidSchedulers.mainThread())
                            .map(GetPurchasesResponse::getList)
                            .map(list -> list == null ? EMPTY_LIST : list)
                            .flatMap(rx.Observable::from)
                            .map(GetPurchasesResponse.PurchaseResponse::getProductId)
                            .filter(item -> PREMIUM_SKU_ID.equals(item))
                            .map(item -> true)
                            .firstOrDefault(false),
                    ReactiveBilling.getInstance(context).purchaseFlow()
                            .doOnNext(this::recordPurchase)
                            .map(PurchaseResponse::isSuccess)
            )
    );
}
 
Example 3
Source File: PurchasesService.java    From Building-Professional-Android-Applications with MIT License 6 votes vote down vote up
public Observable<Boolean> monitorPurchases(Context context) {
    return RxJavaInterop.toV2Observable(
            rx.Observable.concat(
                    rx.Observable.just(false),
                    ReactiveBilling.getInstance(context)
                            .getPurchases(PurchaseType.PRODUCT, null)
                            .subscribeOn(Schedulers.io())
                            .observeOn(AndroidSchedulers.mainThread())
                            .map(GetPurchasesResponse::getList)
                            .flatMap(rx.Observable::from)
                            .map(GetPurchasesResponse.PurchaseResponse::getProductId)
                            .filter(item -> PREMIUM_SKU_ID.equals(item))
                            .map(item -> true)
                            .firstOrDefault(false),
                    ReactiveBilling.getInstance(context).purchaseFlow()
                            .doOnNext(this::recordPurchase)
                            .map(PurchaseResponse::isSuccess)
            )
    );
}
 
Example 4
Source File: PurchasesService.java    From Building-Professional-Android-Applications with MIT License 5 votes vote down vote up
public Observable<Response> purchasePremium(Context context) {
    analytics.logCheckoutStart(PREMIUM_SKU_ID);
    return RxJavaInterop.toV2Observable(
            ReactiveBilling.getInstance(context)
                    .startPurchase(PREMIUM_SKU_ID, PurchaseType.PRODUCT, null, null)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
    );
}
 
Example 5
Source File: PurchasesService.java    From Building-Professional-Android-Applications with MIT License 5 votes vote down vote up
public Observable<Response> purchasePremium(Context context) {
    return RxJavaInterop.toV2Observable(
            ReactiveBilling.getInstance(context)
                    .startPurchase(PREMIUM_SKU_ID, PurchaseType.PRODUCT, null, null)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
    );
}
 
Example 6
Source File: PurchasesService.java    From Building-Professional-Android-Applications with MIT License 5 votes vote down vote up
public Observable<Response> purchasePremium(Context context) {
    analytics.logCheckoutStart(PREMIUM_SKU_ID);
    return RxJavaInterop.toV2Observable(
            ReactiveBilling.getInstance(context)
                    .startPurchase(PREMIUM_SKU_ID, PurchaseType.PRODUCT, null, null)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
    );
}
 
Example 7
Source File: ProviderFacade.java    From moVirt with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 8
Source File: PurchasesService.java    From Building-Professional-Android-Applications with MIT License 4 votes vote down vote up
public Observable<PurchaseResponse> DmonitorPurchases(Context context) {
    return RxJavaInterop.toV2Observable(
            ReactiveBilling.getInstance(context).purchaseFlow()
                    .doOnNext(this::recordPurchase)
    );
}
 
Example 9
Source File: PurchasesService.java    From Building-Professional-Android-Applications with MIT License 4 votes vote down vote up
public Observable<PurchaseResponse> DmonitorPurchases(Context context) {
    return RxJavaInterop.toV2Observable(
            ReactiveBilling.getInstance(context).purchaseFlow()
                    .doOnNext(this::recordPurchase)
    );
}
 
Example 10
Source File: ProviderFacade.java    From moVirt with Apache License 2.0 4 votes vote down vote up
@NonNull
public Observable<List<E>> asObservable() {
    return RxJavaInterop.toV2Observable(asObservableInternal(THROTTLE_BATCH));
}
 
Example 11
Source File: ProviderFacade.java    From moVirt with Apache License 2.0 4 votes vote down vote up
@NonNull
public Observable<List<E>> asObservable(int throttle) {
    return RxJavaInterop.toV2Observable(asObservableInternal(throttle));
}