Last active
September 23, 2017 14:54
-
-
Save Pavneet-Sing/31f593e3a9b523edb6e42e83f0bc0c00 to your computer and use it in GitHub Desktop.
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
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