@@ -0,0 +1,1711 @@
+package com.movies.tobi.popularmovies.popularstream;%0A%0Aimport android.support.annotation.NonNull;%0A%0Aimport com.movies.tobi.popularmovies.BuildConfig;%0Aimport com.movies.tobi.popularmovies.backend.Backend;%0A%0Aimport java.util.List;%0A%0Aimport retrofit2.Retrofit;%0Aimport retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;%0Aimport retrofit2.converter.gson.GsonConverterFactory;%0Aimport rx.Observable;%0Aimport rx.android.schedulers.AndroidSchedulers;%0Aimport rx.functions.Func1;%0Aimport rx.schedulers.Schedulers;%0A%0Apublic class PopularStreamApiDatasource %7B%0A%0A    private final Backend backend;%0A%0A    PopularStreamApiDatasource(Backend backend) %7B%0A        this.backend = backend;%0A    %7D%0A%0A    public PopularStreamApiDatasource() %7B%0A        this(new Retrofit.Builder()%0A                     .baseUrl(Backend.SERVICE_ENDPOINT)%0A                     .addConverterFactory(GsonConverterFactory.create())%0A                     .addCallAdapterFactory(RxJavaCallAdapterFactory.create())%0A                     .build().create(Backend.class));%0A    %7D%0A%0A    //TODO: map to List%3CMoviePoster%3E%0A    public Observable%3CList%3CApiMoviePoster%3E%3E getPopularPosters() %7B%0A        return backend.popularStream(BuildConfig.API_KEY)%0A                .subscribeOn(Schedulers.io())%0A                .map(toMoviePosters())%0A                .observeOn(AndroidSchedulers.mainThread());%0A    %7D%0A%0A    @NonNull%0A    private Func1%3CApiPopularMoviesResponse, List%3CApiMoviePoster%3E%3E toMoviePosters() %7B%0A        return new Func1%3CApiPopularMoviesResponse, List%3CApiMoviePoster%3E%3E() %7B%0A            @Override%0A            public List%3CApiMoviePoster%3E call(ApiPopularMoviesResponse apiPopularMoviesResponse) %7B%0A                return apiPopularMoviesResponse.results;%0A            %7D%0A        %7D;%0A    %7D%0A%0A%7D%0A

Add PopularStreamApiDatasource to fetch the popular stream