rx-android

RxJava data from DB with onscreen list

杀马特。学长 韩版系。学妹 提交于 2019-12-25 08:04:57
问题 I've just begun to learn RxJava and I'm a little bit lost. My scenario is the following: A local NoSQL key-value database where I store some data. The problem is that the endpoint can add data to this DB and also the user can delete some of it. I'm displaying this data as an on-screen list (RecyclerView). I'd like to know what is the best approach to always know what's the most up to date data from the DB in a single place so I can update the UI accordingly. 回答1: What you're looking for is a

How to make multiple requests with reactive android and retrofit

最后都变了- 提交于 2019-12-25 07:50:13
问题 I have presenter which calls getShops() method. Observable<List<Shop>> observable = interactor.getData(); Subscription subscription = observable .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Subscriber<List<Shop>>() { @Override public void onCompleted() { view.hideProgress(); } @Override public void onError(Throwable e) { super.onError(e); view.hideProgress(); } @Override public void onNext(List<Shop> shops) { handleShops(shops); view.onSuccess

Sort collection of objects with Reactive Extensions in Java?

断了今生、忘了曾经 提交于 2019-12-25 02:06:34
问题 How can I can sort a collection of objects using rxjava based on one or more fields of the objects? public class Car { public String model; public int numberOfWheels; public String color; public int yearOfProduction; } List<Car> cars = new ArrayList<>(); cars.add(...); cars.add(...); Observable<List<Car>> getCars() { Observable.just(cars) }; Observable<List<Car>> getCarsSortedByModel() { ??? }; Observable<List<Car>> getCarsSortedByColor() { ??? }; Observable<List<Car>>

How to respond to BLE characteristic notifications by sending a new write command

我的未来我决定 提交于 2019-12-24 20:19:04
问题 I'm updating an app to use RxAndroidBLE, and struggling with how to translate my existing callback pattern into an Rx pattern. In particular, I need to respond to characteristic notifications in different ways depending on the received data, and send a specific write command back to the device (which will then cause the characteristic to be updated, in a loop). The rationale behind this is that the BLE device I'm integrating with has a special custom characteristic, to which we can send

Retrofit2:adapter-rxjava Certificate issue

ε祈祈猫儿з 提交于 2019-12-24 20:17:10
问题 I have the following dependencies in my android project: implementation 'com.squareup.retrofit2:converter-gson:2.1.0' implementation 'com.squareup.retrofit2:retrofit:2.2.0' implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1' implementation 'com.squareup.okhttp3:okhttp:3.7.0' implementation 'io.reactivex.rxjava2:rxjava:2.2.7' implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0' However, the 'com.squareup.retrofit2

How to pass custom pojo as parameter to the interface method call in rxjava2 Observable?

半腔热情 提交于 2019-12-24 12:18:23
问题 Current code Observable.from(listMovie)//list of movie .flatMap(new Func1<Movie, Observable<FavMovieRes>>() { @Override public Observable<FavMovieRes> call(Movie movie) { return moviesAPI.makeMovieFav(userId), sessionId, new MakeMovieFav("movie", movie.getId(), movie.isFavList())); } }) .subscribe(new Subscriber<FavMovieRes>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(FavMovieRes favMovieRes) { } }); In above code I

How to pass variable parameters to Observer?

↘锁芯ラ 提交于 2019-12-24 00:48:48
问题 I have two Observers that are merged with a flatMap. The first observer returns a value that is used when the second is called. Observable<Integer> mergedObservers = firstAPI.getFirstInfo(userLat, userLong) .flatMap(resultFirstObservable -> { try { return secondApi.getSecondInfo(resultFirstObservable.body().string(), "3") .onErrorResumeNext(e -> { e.printStackTrace(); return secondApi.getSecondInfo("defaultValue", "3"); }); } catch (IOException e) { e.printStackTrace(); secondApi

RxJava, Proguard and sun.misc.Unsafe

本小妞迷上赌 提交于 2019-12-23 15:49:20
问题 I have problems with RxJava (1.1.0) when using Proguard . I didn't change RxJava version nor its .pro file, but after updating OkHttp I couldn't compile using Proguard because I had warnings about sun.misc.Unsafe not being present. rxJava.pro -keep class rx.schedulers.Schedulers { public static <methods>; } -keep class rx.schedulers.ImmediateScheduler { public <methods>; } -keep class rx.schedulers.TestScheduler { public <methods>; } -keep class rx.schedulers.Schedulers { public static **

Why debounce() with toList() doen't working in RxAndroid?

此生再无相见时 提交于 2019-12-23 09:25:32
问题 While I'm using debounce() ,then fetch data from backend and the data I want to convert to another data and lastly use toList() . when I'm using toList() nothing happens no any log not in subscribe and error ,without toList() it works and subscribe() method enters as much as I have list of books, I tested the second part of code it without debounce() just getItems() and using toList() it works. Below is my code the first part with debounce() and itList() which is not working and the second

Migrate from RxAndroid 1.x to 2.x (RxJava included)

不想你离开。 提交于 2019-12-22 12:23:52
问题 I have a project running RxAndroid 1.x (everythings works). I am trying to migrate to 2.x version. My gradle file: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:24.2.1' compile 'com.android.support:design:24.2.1' compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.squareup.retrofit2:converter-gson:2.1.0' //compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' compile 'com.squareup.okhttp3:okhttp:3.4.1' compile 'com.squareup