当前位置: 首页>>代码示例>>Java>>正文


Java Single.zip方法代码示例

本文整理汇总了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);
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:21,代码来源:BookmarkPresenterTest.java

示例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);
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:21,代码来源:BookmarkPresenterTest.java

示例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);
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:23,代码来源:BookmarkPresenterTest.java

示例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);
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:23,代码来源:BookmarkPresenterTest.java

示例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);
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:23,代码来源:BookmarkPresenterTest.java

示例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);
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:24,代码来源:BookmarkPresenterTest.java

示例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());
    });
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:19,代码来源:StarredViewModel.java

示例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"));
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:22,代码来源:MusicRemoteSource.java

示例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"));
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:21,代码来源:MusicRemoteSource.java

示例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"));
}
 
开发者ID:vpaliyX,项目名称:Melophile,代码行数:24,代码来源:MusicRemoteSource.java

示例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;
                }
            });
}
 
开发者ID:RikkaApps,项目名称:FCM-for-Mojo,代码行数:12,代码来源:DiscussWhitelistActivity.java

示例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;
                }
            });
}
 
开发者ID:RikkaApps,项目名称:FCM-for-Mojo,代码行数:12,代码来源:GroupWhitelistActivity.java

示例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);
                }
            });
}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:13,代码来源:RxUtils.java

示例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();
    }*/
}
 
开发者ID:newbiechen1024,项目名称:NovelReader,代码行数:73,代码来源:BookSortPresenter.java


注:本文中的io.reactivex.Single.zip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。