Guest User

Untitled

a guest
Nov 21st, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. private void loadData() {
  2.  
  3. final ApiService api = ApiClient.getApiService();
  4.  
  5. Call<ItemList> call = api.getFairyTailsJSON();
  6.  
  7.  
  8. call.enqueue(new Callback<ItemList>() {
  9. @Override
  10. public void onResponse(Call<ItemList> call, Response<ItemList> response) {
  11. if (response.isSuccessful()) {
  12.  
  13. itemList = response.body().getItems();
  14.  
  15. adapter = new ItemsAdapter(MainActivity.this, itemList);
  16. adapter.setItemSendId(MainActivity.this);
  17. recyclerView.setLayoutManager(new GridLayoutManager(MainActivity.this, 1));
  18. recyclerView.setItemAnimator(new DefaultItemAnimator());
  19. recyclerView.setAdapter(adapter);
  20.  
  21. } else {
  22. Toast.makeText(MainActivity.this, "Не удается найти данные для отображения", Toast.LENGTH_SHORT).show();
  23. }
  24. }
  25.  
  26. @Override
  27. public void onFailure(Call<ItemList> call, Throwable t) {
  28. Toast.makeText(MainActivity.this, "Нет доступа к сайту", Toast.LENGTH_SHORT).show();
  29. }
  30. });
  31. }
Add Comment
Please, Sign In to add comment