コード例 #1
0
  private void bind(Photos photos) {
    mSwipeRefreshLayout.setRefreshing(false);
    mPhotos = photos;
    mPhotosAdapter = new PhotosAdapter(mPhotos.getPhotos());
    mRecyclerView.setAdapter(mPhotosAdapter);

    Observable.merge(
            mPhotosAdapter
                .getThumbnailClickedSubject()
                .filter(PhotosValidator::isSourceValid)
                .map(Photo::getSourceUrl),
            mPhotosAdapter
                .getItemClickedSubject()
                .filter(photo -> StringUtils.isValidUrl(photo.getPermalink()))
                .map(Photo::getPermalink))
        .compose(bindUntilEvent(ActivityEvent.DESTROY))
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(OnlyNextObserver.forAction(this::view));
  }
コード例 #2
0
 private void merge(Photos photos) {
   mSwipeRefreshLayout.setRefreshing(false);
   mPhotos.mergeWith(photos);
   mPhotosAdapter.notifyDataSetChanged();
 }