Skip to content

Commit

Permalink
Merge pull request nickbutcher#77 from mattprecious/mattp/unsuccessfu…
Browse files Browse the repository at this point in the history
…l-response

Check response status before reading body
  • Loading branch information
nickbutcher committed Mar 29, 2016
2 parents b5be97b + 6048bf0 commit 64977f6
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,23 @@ protected void loadData(int page) {

@Override
public void onResponse(Call<List<Like>> call, Response<List<Like>> response) {
loadFinished();
final List<Like> likes = response.body();
moreDataAvailable = likes.size() == DribbbleService.PER_PAGE_DEFAULT;
onDataLoaded(likes);
shotLikesCall = null;
if (response.isSuccessful()) {
loadFinished();
final List<Like> likes = response.body();
moreDataAvailable = likes.size() == DribbbleService.PER_PAGE_DEFAULT;
onDataLoaded(likes);
shotLikesCall = null;
} else {
failure();
}
}

@Override
public void onFailure(Call<List<Like>> call, Throwable t) {
failure();
}

private void failure() {
loadFinished();
moreDataAvailable = false;
shotLikesCall = null;
Expand Down

0 comments on commit 64977f6

Please sign in to comment.