Skip to content

Instantly share code, notes, and snippets.

@rohans-doordash
Last active June 29, 2017 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohans-doordash/137dbbd8e4a58884c8c96f146ad11974 to your computer and use it in GitHub Desktop.
Save rohans-doordash/137dbbd8e4a58884c8c96f146ad11974 to your computer and use it in GitHub Desktop.
Fetch restaurant list using Retrofit
public void getRestaurants(double lat, double lng) {
ddApi.getRestaurants(lat, lng, new Callback<List<Restaurant>>() {
@Override
public void onResponse(@NonNull Call<List<Restaurant>> call,
@NonNull Response<List<Restaurant>> response) {
if (response.isSuccessful() && response.body() != null) {
// update adapter with restaurants
} else {
// display the error message contained in response.errorBody()
}
}
@Override
public void onFailure(@NonNull Call<List<Restaurant>> call, @NonNull Throwable t) {
// display a network error message
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment