本文整理匯總了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;
}
});
}