rx-java

RxJava 1 and RxJava 2 in the same project [duplicate]

╄→尐↘猪︶ㄣ 提交于 2020-01-11 11:03:54
问题 This question already has answers here : How to resolve Duplicate files copied in APK META-INF/rxjava.properties (7 answers) Closed 2 years ago . Our project uses RxJava 1: compile 'io.reactivex:rxjava:1.1.6' There is a library we use that uses RxJava 2 internally: compile 'io.reactivex.rxjava2:rxjava:2.0.9' When I do ./gradlew assembleDebug I get this error: com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK

RxJava 1 and RxJava 2 in the same project [duplicate]

大憨熊 提交于 2020-01-11 11:01:57
问题 This question already has answers here : How to resolve Duplicate files copied in APK META-INF/rxjava.properties (7 answers) Closed 2 years ago . Our project uses RxJava 1: compile 'io.reactivex:rxjava:1.1.6' There is a library we use that uses RxJava 2 internally: compile 'io.reactivex.rxjava2:rxjava:2.0.9' When I do ./gradlew assembleDebug I get this error: com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK

CompositeDisposable.clear causes OkHttp to throw java.lang.IllegalStateException: Unbalanced enter/exit

可紊 提交于 2020-01-11 10:08:06
问题 So I have a simple http request using OkHttp. I do this with RxJava on Android. I add this RxJava call to a CompositeDisposable that I then clear on onStop . For some reason that is triggering this exception below. I'm a little unsure about how to fix it. Caused by java.lang.IllegalStateException: Unbalanced enter/exit at okio.AsyncTimeout.enter(AsyncTimeout.java:73) at okio.AsyncTimeout$2.read(AsyncTimeout.java:235) at okio.RealBufferedSource.read(RealBufferedSource.java:47) at okhttp3

Chaining two web service calls using RxJava and Retrofit

风格不统一 提交于 2020-01-11 03:26:26
问题 I am using RxJava and Retrofit.My basic requirement is,i want to chain two api calls, which will get called one after one another. Response received from first api is used as input while calling second api. After reading some stuff on internet i used to flatmap to achieve this. While carrying out this operation i am showing loader.Sometimes it runs smoothly but on some occasions this loader freezes. DDMS shows log of "skipped 300 frames,Application may be doing too much work on its main

What is the difference between Observable and Flowable in RxJava 2.0?

﹥>﹥吖頭↗ 提交于 2020-01-09 16:49:11
问题 Observable and Flowable interfaces seem to be identical. Why Flowable was introduced in RxJava 2.0? When should I prefer to use Flowable over Observable? 回答1: As stated in the documentation: A small regret about introducing backpressure in RxJava 0.x is that instead of having a separate base reactive class, the Observable itself was retrofitted. The main issue with backpressure is that many hot sources, such as UI events, can't be reasonably backpressured and cause unexpected

Rx java - difficult case

社会主义新天地 提交于 2020-01-07 08:35:08
问题 Suppose Observable<Integer> obs = Observable.just(1, 2, 3, 4, 5); I need a sequence, where each even number of obs multiplied by count of even numbers in obs , and each odd number of obs multiplied by count of odd numbers in obs . I.e. in given case there are 2 evens and 3 odds, so result sequence must be 3 (1 * 3) 4 (2 * 2) 9 (3 * 3) 8 (4 * 2) 15 (5 * 3) How can I do it? 回答1: You can achieve it with splitting the Observable to odd and even streams, then iterate over each stream and multiply

Rx java - difficult case

戏子无情 提交于 2020-01-07 08:34:48
问题 Suppose Observable<Integer> obs = Observable.just(1, 2, 3, 4, 5); I need a sequence, where each even number of obs multiplied by count of even numbers in obs , and each odd number of obs multiplied by count of odd numbers in obs . I.e. in given case there are 2 evens and 3 odds, so result sequence must be 3 (1 * 3) 4 (2 * 2) 9 (3 * 3) 8 (4 * 2) 15 (5 * 3) How can I do it? 回答1: You can achieve it with splitting the Observable to odd and even streams, then iterate over each stream and multiply

how to use worker thread in RxAndroid

非 Y 不嫁゛ 提交于 2020-01-07 06:26:43
问题 I am trying to use RxAndroid as shown in the below posted code. firstly, I know that to use .delay() I have to have it work on a worker thread through "Schedulers.io" but Schedulers class does not provide or have ".io" thread.How to use it lib compile 'io.reactivex.rxjava2:rxjava:2.0.1' compile 'io.reactivex.rxjava2:rxandroid:2.0.1' code : Observable observable1 = Observable.just("2"); Observable observable2 = Observable.just("7"); Observable observable = Observable.zip(observable1,

How to make a HTTP request to check a content type with RxJava 2?

主宰稳场 提交于 2020-01-07 05:43:06
问题 I need to get the content type from a specific URL. I know that we can do it by simply coding: URL url = new URL("https://someurl.com"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("HEAD"); // Request Method: GET/POST/UPDATE... connection.connect(); String contentType = connection.getContentType(); Since this blocks the UI thread (a synchronous operation), how to make a HTTP request using RxJava 2 on Android? Notes: I don't want to make

How to make a HTTP request to check a content type with RxJava 2?

孤者浪人 提交于 2020-01-07 05:42:11
问题 I need to get the content type from a specific URL. I know that we can do it by simply coding: URL url = new URL("https://someurl.com"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("HEAD"); // Request Method: GET/POST/UPDATE... connection.connect(); String contentType = connection.getContentType(); Since this blocks the UI thread (a synchronous operation), how to make a HTTP request using RxJava 2 on Android? Notes: I don't want to make