示例#1
0
  /**
   * 获取某个应用的详情
   *
   * @param appID
   * @param action_url
   * @return
   */
  public AppsBean getAppDetail(int appID) {
    AppsBean appBean = new AppsBean();
    param.clear();
    param.put(RequestParam.Param.APPID, String.valueOf(appID));
    String jsonStr =
        mNetUtil.getAppsByStatus(
            param, RequestParam.SERVICE_ACTION_URL + RequestParam.Action.GETAPPDETAIL);
    AppLog.d(TAG, "jsonStr=" + jsonStr);
    if (jsonStr.equals(RequestParam.NET_ERROR)) {
      return null;
    }
    try {
      JSONObject jsonObj = new JSONObject(jsonStr);
      JSONObject appObj = null;
      if (jsonObj.has("app")) {
        appObj = jsonObj.getJSONObject("app");
        if (null == appObj.getString("cname") || appObj.getString("cname").equals("")) {
          return appBean;
        }
      } else {
        return appBean;
      }

      appBean.setID(appObj.getInt("id"));
      appBean.setAppName(appObj.getString("cname"));
      // appBean.setPkgName(appO);
      appBean.setRemark(appObj.getString("remark"));
      appBean.setScore(appObj.getString("score"));
      appBean.setApkUrl(RequestParam.SERVICE_IMAGE_URL + appObj.getString("filepath"));
      String imageSrc = appObj.getString("icon");
      String[] tempStr = imageSrc.split("/");
      appBean.setNatImageUrl(path + tempStr[tempStr.length - 1]);
      appBean.setSerImageUrl(RequestParam.SERVICE_IMAGE_URL + imageSrc);
      appBean.setSize(appObj.getInt("size"));
      appBean.setVersion(appObj.getString("version"));
      appBean.setTypeName(appObj.getString("typeName"));
      appBean.setCreateTime(appObj.getString("createtime"));
    } catch (JSONException e) {
      e.printStackTrace();
    }
    //        loadOneImage(appBean,AppDetailedActivity.MSG_SHOW_APP_DETAIL);
    return appBean;
  }
示例#2
0
  /**
   * 根据分类id获得应用信息
   *
   * @return
   */
  public List<AppsBean> getAppsSearchList(String action_url) {
    AppLog.d(
        TAG,
        "---getApps---action_url="
            + action_url
            + ";pageNo="
            + pageBean.getPageNo()
            + pageBean.getKeyWord());
    //        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()));
    param.put(RequestParam.Param.KEYWORD, pageBean.getKeyWord());

    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");
      if (Integer.valueOf(pageTotal.toString()) == 0) {
        pageBean.calculatePageTotal(0);
        return tempList;
      }
      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.setTypeID(typeIDStr.equals("")?-1:Integer.valueOf(typeIDStr));
        apps.setVersion("(" + appObj.getString("version") + ")");
        apps.setTypeName(
            "" + appObj.getString("typeNames").replace("[", "").replace("\"", "").replace("]", ""));
        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();
    }
    return tempList;
  }