Skip to content

Commit

Permalink
Merge pull request esoxjem#71 from Ali-Rezaei/IdlingResource
Browse files Browse the repository at this point in the history
Fix a crash when user displays favourites while no movie is selected
  • Loading branch information
esoxjem authored Jun 5, 2018
2 parents 7da6ea9 + 162518d commit 8ee13bf
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 8ee13bf

Please sign in to comment.