本文整理汇总了Java中io.reactivex.Single.zip方法的典型用法代码示例。如果您正苦于以下问题:Java Single.zip方法的具体用法?Java Single.zip怎么用?Java Single.zip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.Single
的用法示例。
在下文中一共展示了Single.zip方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBookmarkObservableAyahBookmarksByDate
import io.reactivex.Single; //导入方法依赖的package包/类
@Test
public void testBookmarkObservableAyahBookmarksByDate() {
BookmarkModel model = new BookmarkModel(bookmarksAdapter, recentPageModel) {
@Override
public Single<BookmarkData> getBookmarkDataObservable(int sortOrder) {
return Single.zip(
Single.just(new ArrayList<>()),
Single.just(AYAH_BOOKMARKS_LIST),
Single.just(new ArrayList<>()),
BookmarkData::new);
}
};
BookmarkPresenter presenter = makeBookmarkPresenter(model);
BookmarkResult result = getBookmarkResultByDateAndValidate(presenter, false);
assertThat(result.tagMap).isEmpty();
// 1 for the header, plus one row per item
assertThat(result.rows).hasSize(AYAH_BOOKMARKS_LIST.size() + 1);
}
示例2: testBookmarkObservableMixedBookmarksByDate
import io.reactivex.Single; //导入方法依赖的package包/类
@Test
public void testBookmarkObservableMixedBookmarksByDate() {
BookmarkModel model = new BookmarkModel(bookmarksAdapter, recentPageModel) {
@Override
public Single<BookmarkData> getBookmarkDataObservable(int sortOrder) {
return Single.zip(
Single.just(new ArrayList<>()),
Single.just(MIXED_BOOKMARKS_LIST),
Single.just(new ArrayList<>()),
BookmarkData::new);
}
};
BookmarkPresenter presenter = makeBookmarkPresenter(model);
BookmarkResult result = getBookmarkResultByDateAndValidate(presenter, false);
assertThat(result.tagMap).isEmpty();
// 1 for "page bookmarks" and 1 for "ayah bookmarks"
assertThat(result.rows).hasSize(MIXED_BOOKMARKS_LIST.size() + 2);
}
示例3: testBookmarkObservableMixedBookmarksByDateWithRecentPage
import io.reactivex.Single; //导入方法依赖的package包/类
@Test
public void testBookmarkObservableMixedBookmarksByDateWithRecentPage() {
BookmarkModel model = new BookmarkModel(bookmarksAdapter, recentPageModel) {
@Override
public Single<BookmarkData> getBookmarkDataObservable(int sortOrder) {
return Single.zip(
Single.just(TAG_LIST),
Single.just(MIXED_BOOKMARKS_LIST),
Single.just(RECENTS_LIST),
BookmarkData::new);
}
};
when(settings.getLastPage()).thenReturn(42);
BookmarkPresenter presenter = makeBookmarkPresenter(model);
BookmarkResult result = getBookmarkResultByDateAndValidate(presenter, false);
assertThat(result.tagMap).hasSize(2);
// 2 for "current page", 1 for "page bookmarks" and 1 for "ayah bookmarks"
assertThat(result.rows).hasSize(MIXED_BOOKMARKS_LIST.size() + 4);
}
示例4: testBookmarkObservableAyahBookmarksGroupedByTag
import io.reactivex.Single; //导入方法依赖的package包/类
@Test
public void testBookmarkObservableAyahBookmarksGroupedByTag() {
BookmarkModel model = new BookmarkModel(bookmarksAdapter, recentPageModel) {
@Override
public Single<BookmarkData> getBookmarkDataObservable(int sortOrder) {
return Single.zip(
Single.just(TAG_LIST),
Single.just(AYAH_BOOKMARKS_LIST),
Single.just(new ArrayList<>()),
BookmarkData::new);
}
};
BookmarkPresenter presenter = makeBookmarkPresenter(model);
BookmarkResult result = getBookmarkResultByDateAndValidate(presenter, true);
assertThat(result.tagMap).hasSize(2);
// number of tags (or 1) for each bookmark, plus number of tags (headers), plus unsorted
assertThat(result.rows).hasSize(
AYAH_BOOKMARKS_ROW_COUNT_WHEN_GROUPED_BY_TAG + TAG_LIST.size() + 1);
}
示例5: testBookmarkObservableMixedBookmarksGroupedByTag
import io.reactivex.Single; //导入方法依赖的package包/类
@Test
public void testBookmarkObservableMixedBookmarksGroupedByTag() {
BookmarkModel model = new BookmarkModel(bookmarksAdapter, recentPageModel) {
@Override
public Single<BookmarkData> getBookmarkDataObservable(int sortOrder) {
return Single.zip(
Single.just(TAG_LIST),
Single.just(MIXED_BOOKMARKS_LIST),
Single.just(new ArrayList<>()),
BookmarkData::new);
}
};
BookmarkPresenter presenter = makeBookmarkPresenter(model);
BookmarkResult result = getBookmarkResultByDateAndValidate(presenter, true);
assertThat(result.tagMap).hasSize(2);
// number of tags (or 1) for each bookmark, plus number of tags (headers), plus unsorted
assertThat(result.rows).hasSize(
MIXED_BOOKMARKS_ROW_COUNT_WHEN_GROUPED_BY_TAG + TAG_LIST.size() + 1);
}
示例6: testBookmarkObservableMixedBookmarksGroupedByTagWithRecentPage
import io.reactivex.Single; //导入方法依赖的package包/类
@Test
public void testBookmarkObservableMixedBookmarksGroupedByTagWithRecentPage() {
BookmarkModel model = new BookmarkModel(bookmarksAdapter, recentPageModel) {
@Override
public Single<BookmarkData> getBookmarkDataObservable(int sortOrder) {
return Single.zip(
Single.just(TAG_LIST),
Single.just(MIXED_BOOKMARKS_LIST),
Single.just(RECENTS_LIST),
BookmarkData::new);
}
};
BookmarkPresenter presenter = makeBookmarkPresenter(model);
BookmarkResult result = getBookmarkResultByDateAndValidate(presenter, true);
assertThat(result.tagMap).hasSize(2);
// number of tags (or 1) for each bookmark, plus number of tags (headers), plus unsorted, plus
// current page header, plus current page
assertThat(result.rows).hasSize(
MIXED_BOOKMARKS_ROW_COUNT_WHEN_GROUPED_BY_TAG + TAG_LIST.size() + 1 + 2);
}
示例7: callApi
import io.reactivex.Single; //导入方法依赖的package包/类
@Override
protected void callApi(int page, OnCallApiDone<Repo> onCallApiDone) {
Single<Pageable<Repo>> single;
if (staredCount != null && (staredCount.getValue() == null || staredCount.getValue() < 0)) {
single = Single.zip(userRestService.getStarred(targetUser, page),
userRestService.getStarredCount(targetUser), (repoPageable, count) -> {
if (count != null){
staredCount.setValue(count.getLast());
}
return repoPageable;
});
} else {
single = userRestService.getStarred(targetUser, page);
}
execute(true, single, repoPageable -> {
onCallApiDone.onDone(repoPageable.getLast(), page == 1, repoPageable.getItems());
});
}
示例8: getPlaylistsBy
import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<List<PlaylistEntity>> getPlaylistsBy(List<String> categories) {
if(categories!=null) {
Single<List<PlaylistEntity>> start = Single.just(new LinkedList<>());
for(String category:categories){
start=Single.zip(start,service.searchPlaylists(PlaylistEntity
.Filter.start()
.byName(category)
.limit(100)
.createOptions())
.onErrorResumeNext(Single.just(new ArrayList<>())),(first,second)->{
if(second!=null){
first.addAll(second);
}
return first;
});
}
return start.map(filter::filterPlaylists);
}
return Single.error(new IllegalArgumentException("categories are null"));
}
示例9: getTracksBy
import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<List<TrackEntity>> getTracksBy(List<String> categories) {
if(categories!=null) {
Single<List<TrackEntity>> start = Single.just(new LinkedList<>());
for(String category:categories){
start=Single.zip(start,service.searchTracks(TrackEntity
.Filter.start()
.byTags(category)
.createOptions())
.onErrorResumeNext(Single.just(new ArrayList<>())),(first,second)->{
if(second!=null){
first.addAll(second);
}
return first;
});
}
return start.map(filter::filterTracks);
}
return Single.error(new IllegalArgumentException("categories are null"));
}
示例10: getUserBy
import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<UserDetailsEntity> getUserBy(String id) {
if(id!=null){
Single<List<TrackEntity>> singleTracks=service.fetchUserTracks(id)
.subscribeOn(schedulerProvider.multi());
Single<List<PlaylistEntity>> singlePlaylists=service.fetchUserPlaylists(id)
.subscribeOn(schedulerProvider.multi());
Single<UserEntity> singleUser=service.fetchUser(id)
.subscribeOn(schedulerProvider.multi());
return Single.zip(singleUser,
singleTracks.onErrorResumeNext(Single.just(new ArrayList<>())),
singlePlaylists.onErrorResumeNext(Single.just(new ArrayList<>())),
(user,tracks,playlists)->{
UserDetailsEntity userDetails=new UserDetailsEntity();
userDetails.setUserEntity(user);
userDetails.setTracks(filter.filterTracks(tracks));
userDetails.setPlaylists(filter.filterPlaylists(playlists));
return userDetails;
});
}
return Single.error(new IllegalArgumentException("id is null"));
}
示例11: startFetchWhitelistState
import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<? extends WhitelistState> startFetchWhitelistState() {
return Single.zip(FFMService.getDiscussWhitelist(), OpenQQService.getDiscussesInfo(),
new BiFunction<DiscussWhitelistState, List<Discuss>, DiscussWhitelistState>() {
@Override
public DiscussWhitelistState apply(DiscussWhitelistState state, List<Discuss> groups) throws Exception {
state.generateStates(groups);
return state;
}
});
}
示例12: startFetchWhitelistState
import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public Single<? extends WhitelistState> startFetchWhitelistState() {
return Single.zip(FFMService.getGroupWhitelist(), OpenQQService.getGroupsBasicInfo(),
new BiFunction<GroupWhitelistState, List<Group>, GroupWhitelistState>() {
@Override
public GroupWhitelistState apply(GroupWhitelistState state, List<Group> groups) throws Exception {
state.generateStates(groups);
return state;
}
});
}
示例13: toCommentDetail
import io.reactivex.Single; //导入方法依赖的package包/类
public static <T> Single<DetailBean<T>> toCommentDetail(Single<T> detailSingle,
Single<List<CommentBean>> bestCommentsSingle,
Single<List<CommentBean>> commentsSingle){
return Single.zip(detailSingle, bestCommentsSingle, commentsSingle,
new Function3<T, List<CommentBean>, List<CommentBean>, DetailBean<T>>() {
@Override
public DetailBean<T> apply(T t, List<CommentBean> commentBeen,
List<CommentBean> commentBeen2) throws Exception {
return new DetailBean<T>(t,commentBeen,commentBeen2);
}
});
}
示例14: refreshSortBean
import io.reactivex.Single; //导入方法依赖的package包/类
@Override
public void refreshSortBean() {
//这个最好是设定一个默认时间采用Remote加载,如果Remote加载失败则采用数据中的数据。我这里先写死吧
Single<BookSortPackage> sortSingle = RemoteRepository.getInstance()
.getBookSortPackage();
Single<BookSubSortPackage> subSortSingle = RemoteRepository.getInstance()
.getBookSubSortPackage();
Single<SortPackage> zipSingle = Single.zip(sortSingle, subSortSingle,
new BiFunction<BookSortPackage, BookSubSortPackage, SortPackage>() {
@Override
public SortPackage apply(BookSortPackage bookSortPackage, BookSubSortPackage subSortPackage) throws Exception {
return new SortPackage(bookSortPackage,subSortPackage);
}
});
Disposable disposable = zipSingle.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
(bean) ->{
mView.finishRefresh(bean.sortPackage,bean.subSortPackage);
mView.complete();
}
,
(e) -> {
mView.showError();
LogUtils.e(e);
}
);
addDisposable(disposable);
//保存在数据库中的,之后使用
/* BookSortPackage bean = LocalRepository.getInstance()
.getBookSortPackage();
if (bean == null){
RemoteRepository.getInstance()
.getBookSortPackage()
.doOnSuccess(
(value) ->{
Schedulers.io().createWorker()
.schedule(
() ->{
LocalRepository.getInstance()
.saveBookSortPackage(value);
}
);
}
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new SingleObserver<BookSortPackage>() {
@Override
public void onSubscribe(Disposable d) {
addDisposable(d);
}
@Override
public void onSuccess(BookSortPackage value) {
mView.finishRefresh(value);
mView.complete();
}
@Override
public void onError(Throwable e) {
mView.showError();
}
});
}
else {
mView.finishRefresh(bean);
mView.complete();
}*/
}