Skip to content

Commit

Permalink
Fix a crash when user displays favorites when no movie is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Rezaei committed Jun 1, 2018
1 parent 7da6ea9 commit 162518d
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ private void displayMovies() {
fetchSubscription = moviesInteractor.fetchMovies(currentPage)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doFinally(() -> {
if (!EspressoIdlingResource.getIdlingResource().isIdleNow()) {
EspressoIdlingResource.decrement(); // Set app as idle.
}
})
.subscribe(this::onMovieFetchSuccess, this::onMovieFetchFailed);
}

Expand All @@ -69,7 +74,6 @@ private void showLoading() {
}

private void onMovieFetchSuccess(List<Movie> movies) {
EspressoIdlingResource.decrement();
if (moviesInteractor.isPaginationSupported()) {
loadedMovies.addAll(movies);
} else {
Expand All @@ -81,7 +85,6 @@ private void onMovieFetchSuccess(List<Movie> movies) {
}

private void onMovieFetchFailed(Throwable e) {
EspressoIdlingResource.decrement();
view.loadingFailed(e.getMessage());
}

Expand Down

0 comments on commit 162518d

Please sign in to comment.