Created
August 1, 2017 07:33
-
-
Save hassanabidpk/10ee22e17e017e8feea593d2b0473fb6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private void initiateRestaurantApi(String place, String query,final View recyclerView) { | |
Retrofit retrofit = new Retrofit.Builder() | |
.baseUrl(API_BASE_URL) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.build(); | |
SearchRestaurantApi api = retrofit.create(SearchRestaurantApi.class); | |
Call<SearchRestaurantResponse[]> call = api.getRestaurantsList("json",place,query); | |
progessBar.setVisibility(View.VISIBLE); | |
call.enqueue(new Callback<SearchRestaurantResponse[]>() { | |
@Override | |
public void onResponse(Response<SearchRestaurantResponse[]> response) { | |
if(response.isSuccess()) { | |
Log.d(LOG_TAG, "success - response is " + response.body()); | |
restaurants = Arrays.asList(response.body()); | |
setupRecyclerView((RecyclerView) recyclerView); | |
progessBar.setVisibility(View.GONE); | |
} else { | |
progessBar.setVisibility(View.GONE); | |
Log.d(LOG_TAG, "failure response is " + response.raw().toString()); | |
} | |
} | |
@Override | |
public void onFailure(Throwable t) { | |
Log.d(LOG_TAG, " Error : " + t.getMessage()); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment