/** * 获取某个应用的详情 * * @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; }
/** * 根据分类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; }
/** * 获得应用推荐榜信息,系统启动后默认的 * * @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; }