hu.akarnokd.rxjava.interop.RxJavaInterop Java Examples
The following examples show how to use
hu.akarnokd.rxjava.interop.RxJavaInterop.
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 |
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 |
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 |
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: AccountServiceV3.java From aptoide-client-v8 with GNU General Public License v3.0 | 6 votes |
@Override public Single<Pair<Account, Boolean>> getAccount(String email, String code, String state, String agent) { return RxJavaInterop.toV1Single(aptoideAuthentication.authenticate(code, state, agent)) .flatMap(oAuth2 -> authenticationPersistence.createAuthentication(email, code, oAuth2.getData() .getRefreshToken(), oAuth2.getData() .getAccessToken(), AptoideAccountManager.APTOIDE_SIGN_UP_TYPE) .andThen(authenticationPersistence.getAuthentication() .flatMap(auth -> getAccount(auth.getEmail()).map( account -> Pair.create(account, oAuth2.getSignup()))))) .onErrorResumeNext(throwable -> { if (throwable instanceof AptoideWsV3Exception) { AptoideWsV3Exception exception = (AptoideWsV3Exception) throwable; return Single.error(new AccountException(exception)); } return Single.error(throwable); }); }
Example #5
Source File: RxJavaBindingUtils.java From android-mvvm with Apache License 2.0 | 5 votes |
@BindingConversion @Nullable public static <U extends ViewModel> io.reactivex.Observable<List<ViewModel>> toV1GenericList(@Nullable Observable<List<U>> specificList) { return specificList == null ? null : RxJavaInterop.toV2Observable(specificList).map(new Function<List<U>, List<ViewModel>>() { @Override public List<ViewModel> apply(List<U> ts) throws Exception { return new ArrayList<ViewModel>(ts); } }); }
Example #6
Source File: PurchasesService.java From Building-Professional-Android-Applications with MIT License | 5 votes |
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: PurchasesService.java From Building-Professional-Android-Applications with MIT License | 5 votes |
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 #8
Source File: PurchasesService.java From Building-Professional-Android-Applications with MIT License | 5 votes |
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 #9
Source File: FieldUtils.java From android-mvvm with Apache License 2.0 | 5 votes |
@NonNull public static <T> rx.Observable<T> toObservable(@NonNull final ObservableField<T> field) { return RxJavaInterop.toV1Observable( com.manaschaudhari.android_mvvm.FieldUtils.toObservable(field), BackpressureStrategy.LATEST); }
Example #10
Source File: RoomUpdatePersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
public Single<Boolean> contains(String packageName, boolean isExcluded, boolean isAppcUpgrade) { return RxJavaInterop.toV1Single( updateDao.getByPackageAndExcludedAndUpgrade(packageName, isExcluded, isAppcUpgrade)) .onErrorReturn(throwable -> null) .map(update -> update != null) .subscribeOn(Schedulers.io()); }
Example #11
Source File: RoomEventPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@Override public rx.Completable save(Event event) { return RxJavaInterop.toV1Completable(Completable.create(completableEmitter -> { try { eventDAO.insert(mapper.map(event)); completableEmitter.onComplete(); } catch (JsonProcessingException e) { completableEmitter.onError(e); } }) .subscribeOn(Schedulers.io())); }
Example #12
Source File: RoomEventPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@Override public rx.Completable remove(List<Event> events) { return RxJavaInterop.toV1Completable(Observable.fromIterable(events) .flatMap(event -> { try { return Observable.just(mapper.map(event)); } catch (JsonProcessingException e) { return Observable.error(e); } }) .subscribeOn(Schedulers.io()) .doOnNext(roomEvent -> eventDAO.delete(roomEvent)) .toList() .ignoreElement()); }
Example #13
Source File: RoomInstalledPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
private Observable<List<RoomInstalled>> getInstalledAsList(String packageName) { return RxJavaInterop.toV1Observable(installedDao.getAsListByPackageName(packageName), BackpressureStrategy.BUFFER) .onErrorReturn(throwable -> new ArrayList<>()) .flatMap(installs -> filterCompleted(installs)) .subscribeOn(Schedulers.io()); }
Example #14
Source File: RoomExperimentPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@Override public Completable save(String experimentName, Experiment experiment) { return RxJavaInterop.toV1Completable(io.reactivex.Completable.create(completableEmitter -> { experimentDAO.save(mapper.map(experimentName, experiment)); completableEmitter.onComplete(); }) .subscribeOn(Schedulers.io())); }
Example #15
Source File: RoomExperimentPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@Override public rx.Single<ExperimentModel> get(String identifier) { return RxJavaInterop.toV1Single(experimentDAO.get(identifier) .subscribeOn(Schedulers.io()) .flatMap( roomExperiment -> Single.just(new ExperimentModel(mapper.map(roomExperiment), false)))) .onErrorReturn(throwable -> new ExperimentModel(new Experiment(), true)) .doOnError(Throwable::printStackTrace); }
Example #16
Source File: RoomEventPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@Override public rx.Observable<List<Event>> getAll() { return RxJavaInterop.toV1Observable(eventDAO.getAll() .subscribeOn(Schedulers.io()) .flatMap(roomEvents -> { try { return Observable.just(mapper.map(roomEvents)); } catch (IOException e) { return Observable.error(e); } }), BackpressureStrategy.BUFFER); }
Example #17
Source File: RoomLocalNotificationSyncPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
@Override public Observable<Sync> get(String id) { return RxJavaInterop.toV1Observable(localNotificationSyncDao.get(id), BackpressureStrategy.BUFFER) .subscribeOn(Schedulers.io()) .onErrorReturn(throwable -> null) .map(sync -> { if (sync != null) { return mapper.map(sync, provider); } else { return null; } }); }
Example #18
Source File: ProviderFacade.java From moVirt with Apache License 2.0 | 5 votes |
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 #19
Source File: RoomDownloadPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
public Observable<List<RoomDownload>> getInQueueSortedDownloads() { return RxJavaInterop.toV1Observable(downloadDAO.getInQueueSortedDownloads(), BackpressureStrategy.BUFFER) .onErrorReturn(throwable -> new ArrayList<>()) .subscribeOn(Schedulers.io()); }
Example #20
Source File: RoomDownloadPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
public Observable<List<RoomDownload>> getRunningDownloads() { return RxJavaInterop.toV1Observable(downloadDAO.getRunningDownloads(), BackpressureStrategy.BUFFER) .onErrorReturn(throwable -> new ArrayList<>()) .subscribeOn(Schedulers.io()); }
Example #21
Source File: RoomInstalledPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
public Observable<List<RoomInstalled>> getAsList(String packageName, int versionCode) { return RxJavaInterop.toV1Observable(installedDao.getAsList(packageName, versionCode), BackpressureStrategy.BUFFER) .onErrorReturn(throwable -> new ArrayList<>()) .subscribeOn(Schedulers.io()); }
Example #22
Source File: RoomDownloadPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
public Single<RoomDownload> getAsSingle(String md5) { return RxJavaInterop.toV1Single(downloadDAO.getAsSingle(md5)) .onErrorReturn(throwable -> null) .subscribeOn(Schedulers.io()); }
Example #23
Source File: RoomDownloadPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
public Observable<List<RoomDownload>> getAll() { return RxJavaInterop.toV1Observable(downloadDAO.getAll(), BackpressureStrategy.BUFFER) .defaultIfEmpty(new ArrayList<>()) .subscribeOn(Schedulers.io()); }
Example #24
Source File: RoomDownloadPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
public Observable<RoomDownload> getAsObservable(String md5) { return RxJavaInterop.toV1Observable(downloadDAO.getAsObservable(md5), BackpressureStrategy.BUFFER) .onErrorReturn(throwable -> null) .subscribeOn(Schedulers.io()); }
Example #25
Source File: RoomDownloadPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
public Observable<List<RoomDownload>> getUnmovedFilesDownloads() { return RxJavaInterop.toV1Observable(downloadDAO.getUnmovedFilesDownloads(), BackpressureStrategy.BUFFER) .onErrorReturn(throwable -> new ArrayList<>()) .subscribeOn(Schedulers.io()); }
Example #26
Source File: RoomInstalledPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
public Observable<List<RoomInstalled>> getAllInstalled() { return RxJavaInterop.toV1Observable(installedDao.getAll(), BackpressureStrategy.BUFFER) .flatMap(installs -> filterCompleted(installs)) .subscribeOn(Schedulers.io()); }
Example #27
Source File: RoomInstalledPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
public Observable<List<RoomInstalled>> getAll() { return RxJavaInterop.toV1Observable(installedDao.getAll(), BackpressureStrategy.BUFFER) .subscribeOn(Schedulers.io()); }
Example #28
Source File: RoomInstalledPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
public Observable<List<RoomInstalled>> getAllInstalledSorted() { return RxJavaInterop.toV1Observable(installedDao.getAllSortedAsc(), BackpressureStrategy.BUFFER) .flatMap(installs -> filterCompleted(installs)) .subscribeOn(Schedulers.io()); }
Example #29
Source File: RoomInstalledPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
public Completable remove(String packageName, int versionCode) { return RxJavaInterop.toV1Completable(installedDao.remove(packageName, versionCode)) .subscribeOn(Schedulers.io()); }
Example #30
Source File: RoomDownloadPersistence.java From aptoide-client-v8 with GNU General Public License v3.0 | 4 votes |
public Observable<List<RoomDownload>> getAsList(String md5) { return RxJavaInterop.toV1Observable(downloadDAO.getAsList(md5), BackpressureStrategy.BUFFER) .defaultIfEmpty(new ArrayList<>()) .onErrorReturn(throwable -> new ArrayList<>()) .subscribeOn(Schedulers.io()); }