@Override protected String doInBackground(String... params) { try { // Use BasicNameValuePair to create GET data List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("token", user.getTokenkey())); pairs.add(new BasicNameValuePair("method", "accountapi.getPhotoAlbums")); if (params[0] != null) { if (user_id != null) { pairs.add(new BasicNameValuePair("user_id", "" + params[0])); } else if (page_id != null) { pairs.add(new BasicNameValuePair("module", "pages")); pairs.add(new BasicNameValuePair("item_id", "" + params[0])); } } pairs.add(new BasicNameValuePair("limit", "2")); pairs.add(new BasicNameValuePair("page", "0")); // url request String URL = null; if (Config.CORE_URL == null) { URL = Config.makeUrl(user.getCoreUrl(), null, false); } else { URL = Config.makeUrl(Config.CORE_URL, null, false); } // request GET method to server resultstring = networkUntil.makeHttpRequest(URL, "GET", pairs); JSONObject mainJSON = new JSONObject(resultstring); JSONArray outJson = mainJSON.getJSONArray("output"); arrayOfList = new ArrayList<Album>(); for (int i = 0; i < outJson.length(); i++) { JSONObject JsonAlbum = outJson.getJSONObject(i); Album album = new Album(); album.setAlbum_id(JsonAlbum.getString("album_id")); album.setUser_id(JsonAlbum.getString("user_id")); album.setName(JsonAlbum.getString("name")); album.setDescription(JsonAlbum.getString("description")); album.setTime_phrase(JsonAlbum.getString("time_phrase")); album.setAlbum_total(JsonAlbum.getString("total_photo")); album.setAlbum_pic(JsonAlbum.getJSONObject("photo_sizes").getString("100")); arrayOfList.add(album); } } catch (Exception ex) { // Log.i("comment item", ex.getMessage()); } return resultstring; }
@Override protected String doInBackground(String... params) { try { // Use BasicNameValuePair to create GET data List<NameValuePair> pairs = new ArrayList<NameValuePair>(); pairs.add(new BasicNameValuePair("token", user.getTokenkey())); pairs.add(new BasicNameValuePair("method", "accountapi.getPhotos")); if (page > 1) { pairs.add(new BasicNameValuePair("page", "" + page)); } else { pairs.add(new BasicNameValuePair("page", "undefined")); } if (params[0] != null) { if (user_id != null) { pairs.add(new BasicNameValuePair("user_id", "" + params[0])); } else if (page_id != null) { pairs.add(new BasicNameValuePair("module", "pages")); pairs.add(new BasicNameValuePair("item_id", "" + params[0])); } else if (module_id != null) { pairs.add(new BasicNameValuePair("module", "pages")); pairs.add(new BasicNameValuePair("item_id", "" + params[0])); } if (params[1] != null) { pairs.add(new BasicNameValuePair("album_id", "" + params[1])); } } // url request String URL = null; if (Config.CORE_URL == null) { URL = Config.makeUrl(user.getCoreUrl(), null, false); } else { URL = Config.makeUrl(Config.CORE_URL, null, false); } // request GET method to server resultstring = networkUntil.makeHttpRequest(URL, "GET", pairs); JSONObject mainJSON = new JSONObject(resultstring); JSONArray outJson = mainJSON.getJSONArray("output"); if (stringArrayList == null) { stringArrayList = new ArrayList<String>(); PagerList = new ArrayList<String>(); ImagesId = new ArrayList<String>(); HasLike = new ArrayList<String>(); FeedisLike = new ArrayList<String>(); Total_like = new ArrayList<String>(); Total_comment = new ArrayList<String>(); Itemid = new ArrayList<String>(); Type = new ArrayList<String>(); } if (outJson.length() < 20) { viewmore = 1; } else { float leng = outJson.length(); float itemv = itemView; countImage = leng / itemv; } System.out.println(outJson.length()); System.out.println(countImage); for (int i = 0; i < outJson.length(); i++) { JSONObject JsonPic = outJson.getJSONObject(i); stringArrayList.add(JsonPic.getJSONObject("photo_sizes").getString("100")); ImagesId.add(JsonPic.getString("photo_id")); if (JsonPic.has("feed_total_like")) { HasLike.add(JsonPic.getString("feed_total_like")); Total_like.add(JsonPic.getString("feed_total_like")); } if (JsonPic.has("item_id")) { Itemid.add(JsonPic.getString("item_id")); } if (!JsonPic.isNull("feed_is_liked") && JsonPic.getString("feed_is_liked") != "false") { if (!"".equals(JsonPic.getString("feed_is_liked"))) { FeedisLike.add("feed_is_liked"); } else { FeedisLike.add("null"); } } if (JsonPic.has("total_comment")) { Total_comment.add(JsonPic.getString("total_comment")); } Type.add(JsonPic.getJSONObject("social_app").getString("type_id")); if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD) { PagerList.add(JsonPic.getJSONObject("photo_sizes").getString("240")); } else { PagerList.add(JsonPic.getJSONObject("photo_sizes").getString("500")); } } imagePhotoIds = ImagesId.toArray(new String[ImagesId.size()]); imageUrls = stringArrayList.toArray(new String[stringArrayList.size()]); imageCount = stringArrayList.size(); imagePager = PagerList.toArray(new String[stringArrayList.size()]); imageHasLike = HasLike.toArray(new String[HasLike.size()]); imageFeedisLike = FeedisLike.toArray(new String[FeedisLike.size()]); imageTotal_like = Total_like.toArray(new String[Total_like.size()]); imageTotal_comment = Total_comment.toArray(new String[Total_comment.size()]); imageItemid = Itemid.toArray(new String[Itemid.size()]); imageType = Type.toArray(new String[Type.size()]); imageType = Type.toArray(new String[Type.size()]); } catch (Exception ex) { } return resultstring; }