Last active
June 29, 2017 20:07
-
-
Save rohans-doordash/137dbbd8e4a58884c8c96f146ad11974 to your computer and use it in GitHub Desktop.
Fetch restaurant list using Retrofit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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