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)); }
private void merge(Photos photos) { mSwipeRefreshLayout.setRefreshing(false); mPhotos.mergeWith(photos); mPhotosAdapter.notifyDataSetChanged(); }