@GET
- это HTTP-аннотация, в которой указывается тип запроса и относительный URL-адрес . Возвращаемое значение переносит ответ в объект Call с типом ожидаемого результата.
Коды в вашем вопросе - полный пример:
Call<List<FoodItem>> callFood = service.getFoodItems();
//this line calls getFoodItems method defined in interface via @GET annoation,
//which will send a get request using baseUrl + relative url,
callFood.enqueue(new Callback<List<FoodItem>>() {
@Override
public void onResponse(Call<List<FoodItem>> call, final Response<List<FoodItem>> response) {
if(response!=null) {//the response result will be wrapped in a Call object
List<FoodItem> foodItems = response.body();
listener.onSuccess(foodItems);
}
}
@Override
public void onFailure(Call<List<FoodItem>> call, Throwable t) {
Log.d("Retrofit Failure",t.getLocalizedMessage());
}
});