Skip to content

Instantly share code, notes, and snippets.

@Pavneet-Sing
Last active September 23, 2017 14:54
Show Gist options
  • Save Pavneet-Sing/31f593e3a9b523edb6e42e83f0bc0c00 to your computer and use it in GitHub Desktop.
Save Pavneet-Sing/31f593e3a9b523edb6e42e83f0bc0c00 to your computer and use it in GitHub Desktop.
Retrofit retrofit = new Retrofit.Builder().baseUrl(Navigation_Url).addConverterFactory(GsonConverterFactory.create()).build();
CountryArrayAPI api = retrofit.create(CountryArrayAPI.class);
Call<List> call = api.getCountries();
call.enqueue(new Callback<List>() {
@Override
public void onResponse(Call<List> call, Response<List> response) {
Gson gson = new Gson();
try {
// unchecked cast and it's bad
ArrayList<ListPojo> listPojos = (ArrayList) response.body();
listRetrofitAndroid = new ListRetrofitAndroid(getApplicationContext(), listPojos);
listView.setAdapter(listRetrofitAndroid);
} catch (Exception e) {
Log.d("onResponse", "There is an error");
e.printStackTrace();
}
}
@Override
public void onFailure(Call<List> call, Throwable t) {
Log.d("Failure", t.toString());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment