间隔发送:
String[] codes = irCodeStr.split("\\|");
Observable<String> codesDate = Observable.fromArray(codes);
Observable<Long> intervalDate = Observable.interval(interval, TimeUnit.MILLISECONDS);
Observable.zip(codesDate, intervalDate, (s, aLong) -> s).
subscribeOn(Schedulers.io()).observeOn(Schedulers.computation()).
subscribe(s -> sendIRInner(freq, irManager, s));
合并两条网络数据:
Observable<List<MainPage.News>> loadNews = ApiManager.displayService.getRecommendNewsList(Hardware.current(context).getName(), true);
Observable<List<Video.ShortVideo>> loadShortVideo = ApiManager.displayService.recommendShortVideo();
Disposable disposable = Observable.zip(loadNews, loadShortVideo, (news, shortVideos) -> {
HomeDataContainer container = new HomeDataContainer();
container.recommendNewsList = news;
container.recommendShortVideoList = shortVideos;
return container;
|