rx-android

When to use RxJava in Android and when to use LiveData from Android Architectural Components?

放肆的年华 提交于 2019-11-28 02:38:30
I am not getting the reason to use RxJava in Android and LiveData from Android Architectural Components.It would be really helpful if the usecases and differences between the both are explained along with sample example in the form of code which explains the differences between the both. Android LiveData is a variant of the original observer pattern, with the addition of active/inactive transitions. As such, it is very restrictive in its scope. Using the example described in Android LiveData , a class is created to monitor location data, and register and unregister based on application state.

How to resolve Duplicate files copied in APK META-INF/rxjava.properties

◇◆丶佛笑我妖孽 提交于 2019-11-28 02:29:06
问题 I am using rxjava and rxvolley on my android aplication. When I try to run it I get this error Execution failed for task ':testapp:transformResourcesWithMergeJavaResForDebug'. > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/rxjava.properties File1: C:\Users\Daniel\.gradle\caches\modules-2\files-2.1\io.reactivex\rxjava\1.1.0\748f0546d5c3c27f1aef07270ffea0c45f0c42a4\rxjava-1.1.0.jar File2: C:

RxAndroidBle keeping a persistant connection + Write/Notification handling

偶尔善良 提交于 2019-11-27 23:55:14
I am building an Android application that has specific requirements regarding Bluetooth Low Energy. I need to write to a Write-only characteristic and receive responses on a separate notification characteristic, and I need to do it in many, many activities. Is there a Rx way to send a request on the 1st characteristic, wait for the answer on the second one, then proceed to another request? Also, to share my instance of RxAndroidBle I thought about doing some sort of BleManager Singleton where I would expose the Observables, so I can easily subscribe to them in my Presenter. I just want to

Deliver the first item immediately, 'debounce' following items

北城以北 提交于 2019-11-27 21:03:42
Consider the following use case: need to deliver first item as soon as possible need to debounce following events with 1 second timeout I ended up implementing custom operator based on OperatorDebounceWithTime then using it like this .lift(new CustomOperatorDebounceWithTime<>(1, TimeUnit.SECONDS, Schedulers.computation())) CustomOperatorDebounceWithTime delivers the first item immediately then uses OperatorDebounceWithTime operator's logic to debounce later items. Is there an easier way to achieve described behavior? Let's skip the compose operator, it doesn't solve the problem. I'm looking

Stack overflow when using Retrofit rxjava concatWith

被刻印的时光 ゝ 提交于 2019-11-27 19:51:10
I want to handle pagination in Retrofit using rxjava Observable. I followed the advice from another question . I have more than 100 pages that needs to be fetched, but chain fails around the 20th page and stops any further subscription to the observable with the below log in the logcat 04-04 04:12:11.766 2951-3012/com.example.app I/dalvikvm﹕ threadid=28: stack overflow on call to Ljava/util/concurrent/atomic/AtomicLongFieldUpdater$CASUpdater;.compareAndSet:ZLJJ 04-04 04:12:11.766 2951-3012/com.example.app I/dalvikvm﹕ method requires 56+20+32=108 bytes, fp is 0x94b52350 (80 left) 04-04 04:12:11

Rx Java mergeDelayError not working as expected

房东的猫 提交于 2019-11-27 17:37:53
问题 I'm using RxJava in and Android application with RxAndroid. I'm using mergeDelayError to combine two retro fit network calls into one observable which will process emitted items if either emits one and the error if either has one. This is not working and it is only firing off the onError action when either encounters an error. Now to test this I shifted to a very simple example and still the successAction is never called when I have an onError call. See example below. Observable

Combine a list of Observables and wait until all completed

末鹿安然 提交于 2019-11-27 16:55:33
TL;DR How to convert Task.whenAll(List<Task>) into RxJava ? My existing code uses Bolts to build up a list of asynchronous tasks and waits until all of those tasks finish before performing other steps. Essentially, it builds up a List<Task> and returns a single Task which is marked as completed when all tasks in the list complete, as per the example on the Bolts site . I'm looking to replace Bolts with RxJava and I'm assuming this method of building up a list of async tasks (size not known in advance) and wrapping them all into a single Observable is possible, but I don't know how. I've tried

RxJava Combine Sequence Of Requests

自闭症网瘾萝莉.ら 提交于 2019-11-27 14:43:07
问题 The Problem I have two Apis. Api 1 gives me a List of Items and Api 2 gives me more detailed Information for each of the items I got from Api 1. The way I solved it so far results in bad Performance. The Question Efficent and fast solution to this Problem with the help of Retrofit and RxJava. My Approach At the Moment my Solution Looks like this: Step 1: Retrofit executes Single<ArrayList<Information>> from Api 1. Step 2: I iterate through this Items and make a request for each to Api 2. Step

How to ignore error and continue infinite stream?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 05:38:39
问题 I would like to know how to ignore exceptions and continue infinite stream (in my case stream of locations)? I'm fetching current user position (using Android-ReactiveLocation) and then sending them to my API (using Retrofit). In my case, when exception occurs during network call (e.g. timeout) onError method is invoked and stream stops itself. How to avoid it? Activity: private RestService mRestService; private Subscription mSubscription; private LocationRequest mLocationRequest =

When to use RxJava in Android and when to use LiveData from Android Architectural Components?

て烟熏妆下的殇ゞ 提交于 2019-11-27 04:56:26
问题 I am not getting the reason to use RxJava in Android and LiveData from Android Architectural Components.It would be really helpful if the usecases and differences between the both are explained along with sample example in the form of code which explains the differences between the both. 回答1: Android LiveData is a variant of the original observer pattern, with the addition of active/inactive transitions. As such, it is very restrictive in its scope. Using the example described in Android