本文整理汇总了Java中io.reactivex.Observable.zip方法的典型用法代码示例。如果您正苦于以下问题:Java Observable.zip方法的具体用法?Java Observable.zip怎么用?Java Observable.zip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.Observable
的用法示例。
在下文中一共展示了Observable.zip方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import io.reactivex.Observable; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(new LinearLayoutManager(getBaseContext()));
adapter = new Adapter();
recyclerView.setAdapter(adapter);
loadWithRetroJsoup();
Observable.zip(
Observable.just(""),
Observable.just("&"),
new BiFunction<String, String, String>(){
@Override
public String apply(@NonNull String s, @NonNull String s2) throws Exception {
return null;
}
}
);
}
示例2: processStock
import io.reactivex.Observable; //导入方法依赖的package包/类
public Observable<Tuple2<String, Double>> processStock(List<String> stocks, Function<String, String> f) {
Observable<String> stockNames = Observable.fromIterable(stocks);
Observable<String> urls = stockNames.map(s -> "https://finance.google.com/finance/historical?output=csv&q=" + s);
Observable<Optional<String>> optionalObservable = urls
.subscribeOn(Schedulers.from(executorService))
.flatMap(s -> {
try {
return Observable.just(Optional.of(f.apply(s)));
} catch (Throwable t) {
return Observable.just(Optional.<String>empty());
}
})
.observeOn(Schedulers.computation())
.map(opt -> opt.map(doc -> doc.split("\n")[1].split(",")[4]))
.doOnNext(x -> System.out.println(">>>>" + x));
return Observable.zip(stockNames, optionalObservable, (name, price) ->
new Tuple2<>(name, Double.parseDouble(price.orElse("0.0"))));
}
示例3: createFinalFlowObservable
import io.reactivex.Observable; //导入方法依赖的package包/类
@Override
public Observable<JSONObject> createFinalFlowObservable() {
return Observable.zip(getMe, chapter, new BiFunction<JSONObject, JSONArray, JSONObject>() {
@Override
public JSONObject apply(@NonNull JSONObject jsonObject, @NonNull JSONArray jsonArray) throws Exception {
String name = jsonObject.getString("name");
Log.d("NONO", "TestGroupTask---" + name + ":" + jsonArray.length());
return new JSONObject();
}
});
}
示例4: getAllProducts
import io.reactivex.Observable; //导入方法依赖的package包/类
/**
* Get a list with all products from backend
*/
public Observable<List<Product>> getAllProducts() {
return Observable.zip(getProducts(0), getProducts(1), getProducts(2), getProducts(3),
(products0, products1, products2, products3) -> {
List<Product> productList = new ArrayList<Product>();
productList.addAll(products0);
productList.addAll(products1);
productList.addAll(products2);
productList.addAll(products3);
return productList;
});
}
示例5: get
import io.reactivex.Observable; //导入方法依赖的package包/类
public <CLASS> Observable<CLASS> get(Class<CLASS> theClass) {
return Observable.zip(
onEvent(theClass),
postAsObservable(new AskedEvent(theClass)),
new BiFunction<CLASS, Object, CLASS>() {
@Override
public CLASS apply(@NonNull CLASS neededObject, @NonNull Object _useless) throws Exception {
return neededObject;
}
});
}