I can think of nothing clever. Here to this api http://services.hanselandpetal.com/feeds/flowers.json
but this is not http://mediananny.com/api/category/?offset=0&category_id=0&debug=true
And I just need the second.
Logs show that the public void onFailure(Call<List<Article>> call,Throwable t)
method public void onFailure(Call<List<Article>> call,Throwable t)
Mysticism or something wrong with the second API?
works here:
public class RestManager { private FlowerService mFlowerService; public FlowerService getFlowerService() { if (mFlowerService == null) { Retrofit retrofit = new Retrofit.Builder() .baseUrl(Constants.HTTP.BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .build(); mFlowerService = retrofit.create(FlowerService.class); } return mFlowerService; }
}
but there is no public class RestManager {
private ArticlesService mArticlesService; public ArticlesService getmArticlesService(){ if(mArticlesService == null){ Retrofit retrofit = new Retrofit.Builder() .baseUrl(Constants.HTTP.BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .build(); mArticlesService = retrofit.create(ArticlesService.class); } return mArticlesService; }
}
And the fact of the matter is that no error throws. Just work out here:
mManager = new RestManager(); Call<List<Article>> listCall = mManager.getmArticlesService().getAllArticles(); listCall.enqueue(new Callback<List<Article>>() { @Override public void onResponse(Call<List<Article>> call,Response<List<Article>> response) { if(response.isSuccessful()){ List<Article> articlesList = response.body(); Log.d(LOG_TAG, articlesList.size()+" size of list"); for(int i=0; i< articlesList.size(); i++){ Article article = articlesList.get(i); Log.d(LOG_TAG, article.getTitle()); // mArticleAdapter.addArticle(article); } }else { Log.d(LOG_TAG, "NO responce.............."); int sc = response.code(); switch (sc) { case 400: Log.e("Error 400", "Bad Request"); break; case 404: Log.e("Error 404", "Not Found"); break; default: Log.e("Error", "Generic Error"); } } } @Override public void onFailure(Call<List<Article>> call,Throwable t) { вот это Log.d(LOG_TAG, "NO responce"); } }); }
Throwable t
? - Nofate ♦