rx-java2

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

Why Does Room Delete Operation(With RxJava) Gives UI Thread Error Even Specifying Different Subcribe Thread?

て烟熏妆下的殇ゞ 提交于 2020-01-11 03:08:29
问题 So simply, the DAO @Query("DELETE FROM Things WHERE someIdOfTheThing IN (:listOfId)") abstract fun deleteThings(listOfId: MutableList<String>): Maybe<Int> usage, mDisposables.add(mThingsDao .deleteThings(listOfId) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe({ ... }, { ... }) ) and error, // Cannot access database on the main thread since it may potentially lock the UI for a long period of time. The simple idea i was thinking is to specify subscribeOn

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

RxJava2 - execute call synchronously

柔情痞子 提交于 2020-01-06 08:30:20
问题 I've a TestService , where I do an async task to get my data. I would like to wait for the response before I continue. public List<Data> getData() { List<Data> data = new ArrayList<>(); Disposable disposable = repository.getDataFromApi(false) .observeOn(AndroidSchedulers.mainThread()) .subscribe( newData -> { data.addAll(newData); }, __ -> { }); mCompositeDisposable.add(disposable); //Here I want to stop till "Data" arraylist is filled with data ... do something with data } In Volley I could

com.polidea.rxandroidble2.exceptions.BleCharacteristicNotFoundException: Characteristic not found with UUID

ⅰ亾dé卋堺 提交于 2020-01-06 08:29:20
问题 I'm trying to read an unsolicited data stream from my Bluetooth device. The data should appear as a byte array. Unfortunately, the UUID I'm supplying doesn't seem to be the correct one. What could be going wrong? val stringDeviceUUID = rxBleDevice.bluetoothDevice.uuids[0].toString() val charUUID = UUID.fromString(stringDeviceUUID) println("$stringDeviceUUID = $charUUID?") /* If device if it is not already connected... */ if (rxBleDevice.connectionState != RxBleConnection.RxBleConnectionState

com.polidea.rxandroidble2.exceptions.BleCharacteristicNotFoundException: Characteristic not found with UUID

两盒软妹~` 提交于 2020-01-06 08:29:06
问题 I'm trying to read an unsolicited data stream from my Bluetooth device. The data should appear as a byte array. Unfortunately, the UUID I'm supplying doesn't seem to be the correct one. What could be going wrong? val stringDeviceUUID = rxBleDevice.bluetoothDevice.uuids[0].toString() val charUUID = UUID.fromString(stringDeviceUUID) println("$stringDeviceUUID = $charUUID?") /* If device if it is not already connected... */ if (rxBleDevice.connectionState != RxBleConnection.RxBleConnectionState

Unit testing RxJava in MVP presenter in android

落爺英雄遲暮 提交于 2020-01-06 07:15:15
问题 I am new to TDD. Also new to MVP and Rxjava. I just dive into it and It is worth it. But I stuck at the testing part. I understand the basis of unit testing. It is a little bit difficult for me in beginning. But I stuck here and So how can test the presenter? Here is the Presenter class - public class NewsPresenter { private final RxjavaService service; private final MainView view; private CompositeSubscription subscriptions; public NewsPresenter(RxjavaService service, MainView view) { this

Unit testing RxJava in MVP presenter in android

吃可爱长大的小学妹 提交于 2020-01-06 07:15:10
问题 I am new to TDD. Also new to MVP and Rxjava. I just dive into it and It is worth it. But I stuck at the testing part. I understand the basis of unit testing. It is a little bit difficult for me in beginning. But I stuck here and So how can test the presenter? Here is the Presenter class - public class NewsPresenter { private final RxjavaService service; private final MainView view; private CompositeSubscription subscriptions; public NewsPresenter(RxjavaService service, MainView view) { this