Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. private class ParseTask extends AsyncTask<Void, Void, String> {
  2. //
  3. // HttpURLConnection urlConnection = null;
  4. // BufferedReader reader = null;
  5. // String resultJson = "";
  6. //
  7. // @Override
  8. // protected String doInBackground(Void... params) {
  9. // // получаем данные с внешнего ресурса
  10. // try {
  11. // URL url = new URL("http://ellotv.bigdig.com.ua/api/home/video");
  12. //
  13. // urlConnection = (HttpURLConnection) url.openConnection();
  14. // urlConnection.setRequestMethod("GET");
  15. // urlConnection.connect();
  16. //
  17. // InputStream inputStream = urlConnection.getInputStream();
  18. // StringBuffer buffer = new StringBuffer();
  19. //
  20. // reader = new BufferedReader(new InputStreamReader(inputStream));
  21. //
  22. // String line;
  23. // while ((line = reader.readLine()) != null) {
  24. // buffer.append(line);
  25. // }
  26. //
  27. // resultJson = buffer.toString();
  28. //
  29. // } catch (Exception e) {
  30. // e.printStackTrace();
  31. // }
  32. // return resultJson;
  33. // }
  34. //
  35. // @Override
  36. // protected void onPostExecute(String strJson) {
  37. // super.onPostExecute(strJson);
  38. // // выводим целиком полученную json-строку
  39. // Log.d(LOG_TAG, strJson);
  40. //
  41. // JSONObject dataJsonObj = null;
  42. // String id = "";
  43. //
  44. // try {
  45. // dataJsonObj = new JSONObject(strJson);
  46. // JSONArray items = dataJsonObj.getJSONArray("items");
  47. //
  48. // // 1. достаем инфо
  49. // JSONObject firstpole = items.getJSONObject(1597);
  50. // id = firstpole.getString("id");
  51. // Log.d(LOG_TAG, "id: " + id);
  52. //
  53. // // 2. перебираем и выводим
  54. // for (int i = 0; i < items.length(); i++) {
  55. // JSONObject item = items.getJSONObject(i);
  56. //
  57. // JSONObject pole = item.getJSONObject("items");
  58. //
  59. // String picture = pole.getString("picture");
  60. // String title = pole.getString("title");
  61. // String artist = pole.getString("artist");
  62. // String view_count = pole.getString("view_count");
  63. //
  64. // Log.d(LOG_TAG, "picture" + picture);
  65. // Log.d(LOG_TAG, "title: " + title);
  66. // Log.d(LOG_TAG, "artist: " + artist);
  67. // Log.d(LOG_TAG, "view_count: " + view_count);
  68. // }
  69. //
  70. // } catch (JSONException e) {
  71. // e.printStackTrace();
  72. // }
  73. // }
  74. // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement