Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/searchView' into searchView
Browse files Browse the repository at this point in the history
  • Loading branch information
rijogeorge7 committed Jun 8, 2018
2 parents 6274b4f + f40baab commit 376d3cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,21 @@ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
moviesPresenter.setView(this);
if (savedInstanceState != null) {
movies = savedInstanceState.getParcelableArrayList(Constants.MOVIE);
adapter.notifyDataSetChanged();
moviesListing.setVisibility(View.VISIBLE);
} else {
moviesPresenter.setView(this);
moviesPresenter.firstPage();
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_sort:
moviesPresenter.setView(this);
moviesPresenter.firstPage();
displaySortingOptions();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void setView(MoviesListingView view) {
if(!showingSearchResult){
displayMovies();
}

}

@Override
Expand All @@ -49,6 +50,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 Down Expand Up @@ -104,7 +110,6 @@ private void showLoading() {
}

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

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

Expand Down

0 comments on commit 376d3cf

Please sign in to comment.