|
5 | 5 | import android.util.Pair; |
6 | 6 | import android.view.View; |
7 | 7 |
|
| 8 | +import androidx.appcompat.app.AppCompatActivity; |
| 9 | + |
8 | 10 | import com.rx2androidnetworking.Rx2AndroidNetworking; |
9 | 11 | import com.rxjava2.android.samples.R; |
10 | 12 | import com.rxjava2.android.samples.model.ApiUser; |
|
15 | 17 | import java.util.ArrayList; |
16 | 18 | import java.util.List; |
17 | 19 |
|
18 | | -import androidx.appcompat.app.AppCompatActivity; |
19 | 20 | import io.reactivex.Observable; |
20 | 21 | import io.reactivex.ObservableSource; |
21 | 22 | import io.reactivex.Observer; |
@@ -93,23 +94,25 @@ public void onComplete() { |
93 | 94 | private Observable<List<User>> getCricketFansObservable() { |
94 | 95 | return Rx2AndroidNetworking.get("https://fierce-cove-29863.herokuapp.com/getAllCricketFans") |
95 | 96 | .build() |
96 | | - .getObjectListObservable(User.class); |
| 97 | + .getObjectListObservable(User.class) |
| 98 | + .subscribeOn(Schedulers.io()); |
97 | 99 | } |
98 | 100 |
|
99 | 101 | /* |
100 | | - * This observable return the list of User who loves Football |
101 | | - */ |
| 102 | + * This observable return the list of User who loves Football |
| 103 | + */ |
102 | 104 | private Observable<List<User>> getFootballFansObservable() { |
103 | 105 | return Rx2AndroidNetworking.get("https://fierce-cove-29863.herokuapp.com/getAllFootballFans") |
104 | 106 | .build() |
105 | | - .getObjectListObservable(User.class); |
| 107 | + .getObjectListObservable(User.class) |
| 108 | + .subscribeOn(Schedulers.io()); |
106 | 109 | } |
107 | 110 |
|
108 | 111 | /* |
109 | | - * This do the complete magic, make both network call |
110 | | - * and then returns the list of user who loves both |
111 | | - * Using zip operator to get both response at a time |
112 | | - */ |
| 112 | + * This do the complete magic, make both network call |
| 113 | + * and then returns the list of user who loves both |
| 114 | + * Using zip operator to get both response at a time |
| 115 | + */ |
113 | 116 | private void findUsersWhoLovesBoth() { |
114 | 117 | // here we are using zip operator to combine both request |
115 | 118 | Observable.zip(getCricketFansObservable(), getFootballFansObservable(), |
|
0 commit comments