Skip to content

Instantly share code, notes, and snippets.

Created December 16, 2016 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/566c95dbba1d562d341b527dc7099a6f to your computer and use it in GitHub Desktop.
Save anonymous/566c95dbba1d562d341b527dc7099a6f to your computer and use it in GitHub Desktop.
public class MovieActivityPresenter extends Presenter<MovieActivityView>
public void getSimilarMovies() {
apiInterface.getSimilarMovies(Integer.valueOf(movieID),ApiInterface.KEY)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
moviesResponse -> similarMovies = moviesResponse.getResults(),
throwable -> {},
() -> {
for (Movie m:similarMovies) {
m.setPosterPath(posterURL + m.getPosterPath());
m.setBackdropPath(backdropURL + m.getBackdropPath());
}
view.setMovieDetails();
view.setCastAdapter();
view.setSimilarMoviesAdapter();
}
);
}
@Override
public void onViewDetached() {
super.onViewDetached();
}
}
public abstract class Presenter<V> {
protected V view;
public void onViewAttached(V view) {
this.view = view;
}
public void onViewDetached() {
this.view = null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment