Exemple #1
0
 /**
  * 根据分类id获得应用信息
  *
  * @return
  */
 public List<AppsBean> getAppsList(String action_url) {
   AppLog.d(TAG, "---getApps---action_url=" + action_url + ";pageNo=" + pageBean.getPageNo());
   if (typeId >= 0) {
     param.put(RequestParam.Param.TYPEID, String.valueOf(typeId));
   }
   param.put(RequestParam.Param.PAGENO, String.valueOf(pageBean.getPageNo()));
   param.put(RequestParam.Param.LINENUMBER, String.valueOf(pageBean.getPageSize()));
   String jsonStr = mNetUtil.getAppsByStatus(param, RequestParam.SERVICE_ACTION_URL + action_url);
   if (jsonStr.equals(RequestParam.NET_ERROR)) {
     return null;
   }
   List<AppsBean> tempList = new ArrayList<AppsBean>();
   try {
     JSONObject allObj = new JSONObject(jsonStr);
     if (null == allObj) {
       pageBean.calculatePageTotal(0);
       return tempList;
     }
     JSONObject pageObj = allObj.getJSONObject("page");
     JSONArray listArr = pageObj.getJSONArray("list");
     Object pageTotal = pageObj.get("totalLine");
     pageBean.calculatePageTotal(Integer.valueOf(pageTotal.toString()));
     JSONObject appObj;
     setPath();
     for (int i = 0; i < listArr.length(); i++) {
       appObj = listArr.getJSONObject(i);
       AppsBean apps = new AppsBean();
       apps.setID(appObj.getInt("id"));
       apps.setAppName(appObj.getString("name"));
       //                String typeIDStr=appObj.getString("typeId");
       apps.setPrice(appObj.getDouble("price"));
       //                apps.setTypeID(typeIDStr.equals("")?-1:Integer.valueOf(typeIDStr));
       String imageSrc = appObj.getString("image");
       String[] tempStr = imageSrc.split("/");
       apps.setNatImageUrl(path + tempStr[tempStr.length - 1]);
       apps.setSerImageUrl(RequestParam.SERVICE_IMAGE_URL + imageSrc);
       if (appObj.getString("id") != null
           && !appObj.getString("id").equals("")
           && appObj.getString("id") != null
           && !appObj.getString("id").equals("")
           && appObj.getString("name") != null
           && !appObj.getString("name").equals("")) {
         tempList.add(apps);
       }
     }
   } catch (JSONException e) {
     e.printStackTrace();
   }
   if (pageBean.getPageTotal() == 0) {
     pageBean.setPageNo(0);
   }
   //        loadListImage(tempList,AppStoreActivity.MSG_FINISH_ONE_APP);
   return tempList;
 }
Exemple #2
0
 /**
  * 获得应用推荐榜信息,系统启动后默认的
  *
  * @return
  */
 public List<AppsBean> getRecommendAppsList(String action_url) {
   AppLog.d(TAG, "---getApps---action_url=" + action_url + ";pageNo=" + pageBean.getPageNo());
   param.put(RequestParam.Param.PAGENO, String.valueOf(pageBean.getPageNo()));
   param.put(RequestParam.Param.LINENUMBER, String.valueOf(pageBean.getPageSize()));
   String jsonStr = mNetUtil.getAppsByStatus(param, RequestParam.SERVICE_ACTION_URL + action_url);
   if (jsonStr.equals(RequestParam.NET_ERROR)) {
     return null;
   }
   List<AppsBean> tempList = new ArrayList<AppsBean>();
   try {
     JSONObject jsonObj = new JSONObject(jsonStr);
     if (null == jsonObj) {
       pageBean.calculatePageTotal(0);
       return tempList;
     }
     JSONObject pageObj = jsonObj.getJSONObject("page");
     if (null == jsonObj) {
       pageBean.calculatePageTotal(0);
       return tempList;
     }
     JSONArray listArr = pageObj.getJSONArray("list");
     Object pageTotal = pageObj.get("totalLine");
     pageBean.calculatePageTotal(Integer.valueOf(pageTotal.toString()));
     JSONObject appObj;
     setPath();
     for (int i = 0; i < listArr.length(); i++) {
       appObj = listArr.getJSONObject(i);
       AppsBean apps = new AppsBean();
       apps.setID(appObj.getInt("id"));
       apps.setAppName(appObj.getString("name"));
       String imageSrc = appObj.getString("image");
       apps.setPrice(appObj.getDouble("price"));
       if (appObj.has("packageName")) {
         apps.setPkgName(appObj.getString("packageName"));
       } else {
         apps.setPkgName("");
       }
       if (appObj.has("versionCode")) {
         apps.setVersion(appObj.getString("versionCode"));
       }
       String[] tempStr = imageSrc.split("/");
       apps.setNatImageUrl(path + tempStr[tempStr.length - 1]);
       apps.setSerImageUrl(RequestParam.SERVICE_IMAGE_URL + imageSrc);
       if (appObj.getString("id") != null
           && !appObj.getString("id").equals("")
           && appObj.getString("id") != null
           && !appObj.getString("id").equals("")
           && appObj.getString("name") != null
           && !appObj.getString("name").equals("")) {
         tempList.add(apps);
       }
     }
   } catch (JSONException e) {
     AppLog.d(TAG, "*********error************* getRecommendAppsList json is error");
     e.printStackTrace();
   }
   if (pageBean.getPageTotal() == 0) {
     pageBean.setPageNo(0);
   }
   long time4 = System.currentTimeMillis();
   return tempList;
 }