rx-java

How to bind Radio Buttons using RxJava

拥有回忆 提交于 2020-01-06 20:01:48
问题 I'm following the code of the Qiitanium app (See the highlighted lines in link) and I have trouble figuring out how I can bind RadioButtons Say I have a RadioGroup with R.id.rgMyButtons as Id and it contains 3 RadioButtons "Dead", "Alive", "Body Missing" with Ids are R.id.rbDead, R.id.rbAlive, R.id.rbMissing I set the RadioGroup field as Rx<RadioGroup> radioGroup; I get the view set in onViewCreated as rdGroup = RxView.findById(this, R.id.rgMyButtons); rdGroup.get().setOnCheckedChangeListener

RxAndroid response of one call to make another request

别来无恙 提交于 2020-01-06 08:22:12
问题 I'm new to RxAndroid and trying to chain responses. I'm using this github API to retrieve data. Along with each issue there are comments link and events link associated with it which I want to fetch and update existing object with list of comments and events to form something like this. [ issue: { comments: [ { . . }, { . . } ] events : [ { . . }, { . . } ] ] ] I could retrieve initial response with following code GitHubService gitHubService = ServiceFactory.createServiceFrom(GitHubService

RxAndroid response of one call to make another request

拟墨画扇 提交于 2020-01-06 08:21:12
问题 I'm new to RxAndroid and trying to chain responses. I'm using this github API to retrieve data. Along with each issue there are comments link and events link associated with it which I want to fetch and update existing object with list of comments and events to form something like this. [ issue: { comments: [ { . . }, { . . } ] events : [ { . . }, { . . } ] ] ] I could retrieve initial response with following code GitHubService gitHubService = ServiceFactory.createServiceFrom(GitHubService

How to avoid nested Single in RxJava2

你说的曾经没有我的故事 提交于 2020-01-06 07:15:17
问题 I am fairly new in RxJava pradigm. I am doing following is leading to nested Single objects. tickHappened.map{ func(it) } //I get Single<Single<ArrayList<String>>> Here tickHappened:Single<T> and func<T>(T param):Single<ArrayList<String>> tickHappened.map{ func(it) } //I get Single<Single<ArrayList<String>>> .map { single -> single.map { list -> list.size } } I actually need to return Single<Int> which is the size of the Arraylist passed. I need to use map twice in the above chain which leads

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

What's the correct way to unsubscribe from Single [duplicate]

*爱你&永不变心* 提交于 2020-01-06 07:14:02
问题 This question already has answers here : The result of subscribe is not used (6 answers) Closed 9 months ago . I want to do something after short delay: public void notifyMe() { Single .timer(500, TimeUnit.MILLISECONDS) .subscribeOn(Schedulers.io()) .subscribe(ignore -> service.notifyMe())); } Now I have a warning: "The result of subscribe is not used" . How can I fix it? 回答1: A Single will only call once. Upon calling either method, the Single terminates and the subscription to it ends. Link

mapping custom data RxAndroid with Kotlin

百般思念 提交于 2020-01-06 05:08:11
问题 I am trying to convert examples from this article from Java to Kotlin. I get error from picture at Exmaple 5: And I noticed, that without map() function I don't get this error So, what the point of this error and how to write it right? 回答1: The return value of a lambda in Kotlin is always the last expression in the block. So in this case the result of .map { it.note = it.note.toUpperCase() } is not returning a meaningful value. What you should do instead is this .map { it.note = it.note

How to return FilterResults in AutoCompleteTextView Adapter consuming ApiRest with RxJava or Retrofit2?

那年仲夏 提交于 2020-01-06 04:42:30
问题 I am coding an autocompleteTextView adapter which is filled by an ApiRest. I'm using rxJava and Retrofit 2. but cannot get the filtered result because i dont know how to return the value in asynchronous function. here is my code public class DiagnosticoAutoCompleteAdapter extends BaseAdapter implements Filterable { ... @Override public Filter getFilter() { Filter filter = new Filter() { @Override protected FilterResults performFiltering(CharSequence charSequence) { final FilterResults

Passing parameter to Observable.create

蹲街弑〆低调 提交于 2020-01-06 04:22:06
问题 I am using RXJava on Android for asynchronously access the database. I want to save an object in my database. In this way, I created a method which take a final parameter (the object I want to save) and returns an Observable. At this point I don't care to emit anything so I will call subscriber.onComplete() at the end. Here is my code: public Observable saveEventLog(@NonNull final EventLog eventLog) { return Observable.create(new Observable.OnSubscribe<Object>() { @Override public void call