Couldn't get any data in return onResponse, the result skipped to onFailure.
It works on my other application, data is return and displayed successfully, but the same thing failed on this application.
I tried with other code and still couldn't find out the problem, not a single error message show, any idea?
private void parseJSON() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Api.URL_DATA)
.addConverterFactory(GsonConverterFactory.create())
.build();
Api api = retrofit.create(Api.class);
Call<List<ListItem>> call = api.getList();
call.enqueue(new Callback<List<ListItem>>() {
@Override
public void onResponse(Call<List<ListItem>> call, retrofit2.Response<List<ListItem>> response) {
if (response.isSuccessful()) {
Toast.makeText(getApplicationContext(), "Server returned data", Toast.LENGTH_SHORT).show();
DeveloperList = response.body();
listAdapter.setList(DeveloperList);
progressDialog.hide();
}
else {
Toast.makeText(getApplicationContext(), "Server returned an error", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<List<ListItem>> call, Throwable t) {
progressDialog.hide();
Toast.makeText(getApplicationContext(), "This is an actual network failure...", Toast.LENGTH_SHORT).show();
}
});
}