KeenenCharles / AndroidUnplash

An unofficial Unsplash API library for Android
MIT License
85 stars 22 forks source link

Callback for 404 error code #12

Closed disparate closed 5 years ago

disparate commented 5 years ago

Currently there is no option to get a callback for 404 error.

@Override
public void onResponse(Call<SearchResults> call, Response<SearchResults> response) {
   int statusCode = response.code();
   Log.d(TAG, "Status Code = " + statusCode);
   if(statusCode == 200) {
      SearchResults results = response.body();
      listener.onComplete(results);
   }
   else if(statusCode == 401) {
      Log.d(TAG, "Unauthorized, Check your client Id");
   }
}

Maybe we should invoke listener.onError(statusCode) if it's not 200?

KeenenCharles commented 5 years ago

Yeah, definitely it should do that. I'll see if I can get some time to add this but you're free to submit a PR if you can.

disparate commented 5 years ago

Have a look pls. https://github.com/KeenenCharles/AndroidUnplash/pull/13

KeenenCharles commented 5 years ago

Version 1.0.4 is up now with your changes