/** * 获取用户对应某个应用的评分信息 * * @param userID * @param appID * @return */ public Map<Boolean, Integer> getScorFormService(String userId, int appID) { // public Boolean getScorFormService(String userId,int appID){ param.clear(); param.put(RequestParam.Param.USERID, userId); param.put(RequestParam.Param.APPID, appID + ""); String jsonStr = mNetUtil.getAppsByStatus( param, RequestParam.SERVICE_ACTION_URL + RequestParam.Action.GETUSERISSCORE); Map<Boolean, Integer> map = new HashMap<Boolean, Integer>(); AppLog.d( TAG, "-----------------------getScorFormService jsonStr = " + jsonStr + "--------------------"); if (jsonStr.equals(RequestParam.NET_ERROR)) { return null; } try { JSONObject jsonObj = new JSONObject(jsonStr); if (jsonObj.has("score")) { if (jsonObj.getInt("score") == -1) { AppLog.d(TAG, "----------------------the user is no Score--------------------"); map.put(false, -1); return map; } else { map.put(true, jsonObj.getInt("score")); return map; } } else { return null; } } catch (JSONException e) { AppLog.d(TAG, "-----------------------getScorFormService ERROR!!!!!!!--------------------"); } return null; }
/** * 提交用户评分 * * @param userId * @param appID * @param appScore */ public Boolean setScoreToService(String userId, int appID, Float appScore) { param.clear(); param.put(RequestParam.Param.USERID, userId); param.put(RequestParam.Param.APPID, String.valueOf(appID)); param.put(RequestParam.Param.SCORE, String.valueOf(appScore)); String jsonStr = mNetUtil.getAppsByStatus( param, RequestParam.SERVICE_ACTION_URL + RequestParam.Action.USERVOTE); AppLog.d( TAG, "-----------------------setScoreToService jsonStr = " + jsonStr + "--------------------"); if (jsonStr.equals(RequestParam.NET_ERROR)) { return false; } try { JSONObject jsonObj = new JSONObject(jsonStr); if (jsonObj.has("success")) { if (jsonObj.getBoolean("success") == true) { return true; } else { return false; } } else { return false; } } catch (JSONException e) { e.printStackTrace(); } return null; }
/** * 获取可升级应用 * * @param install已安装应用 * @return */ public List<ApplicationBean> getNativeUpdateAppsList(List<ApplicationBean> install) { List<ApplicationBean> tempList = new ArrayList<ApplicationBean>(); try { String josnString = mNetUtil.connect(con.getApplicationContext(), install); JSONObject json = new JSONObject(josnString); if (!json.has("appList")) { return null; } JSONArray arr = json.getJSONArray("appList"); if (null == arr || arr.length() < 1) { return null; } JSONObject updObj; ApplicationBean tempApp; for (int i = 0; i < arr.length(); i++) { tempApp = new ApplicationBean(); updObj = arr.getJSONObject(i); if (updObj.has("id")) { tempApp.setId(updObj.getInt("id")); } tempApp.setPkgName(updObj.getString("packageName")); tempApp.setAppName(updObj.getString("appName")); tempApp.setVersion(updObj.getString("versionCode")); tempApp.setTypeName(updObj.getString("typeName")); tempApp.setUrl(RequestParam.SERVICE_IMAGE_URL + updObj.getString("url")); tempApp.setIconUrl(RequestParam.SERVICE_IMAGE_URL + updObj.getString("icon")); tempList.add(tempApp); } } catch (Exception e) { e.printStackTrace(); return null; } return tempList; }
/** * 根据json解析获取应用分类信息 * * @return */ public List<AppsBean> getAppsClassList(String action_url) { AppLog.d(TAG, "---getAppsClass---action_url=" + action_url); 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 { JSONArray typesObj = new JSONObject(jsonStr).getJSONArray("Types"); JSONObject appObj; setPath(); for (int i = 0; i < typesObj.length(); i++) { appObj = typesObj.getJSONObject(i); AppsBean apps = new AppsBean(); apps.setID(appObj.getInt("@id")); apps.setAppName(appObj.getString("@name")); String imageSrc = appObj.getString("@nImg"); String[] tempStr = imageSrc.split("//"); String[] temp2Str = tempStr[1].split("/"); apps.setNatImageUrl(path + temp2Str[temp2Str.length - 1]); apps.setSerImageUrl(imageSrc); if (appObj.getString("@id") != null && !appObj.getString("@id").equals("")) { tempList.add(apps); } } } catch (JSONException e) { e.printStackTrace(); } // loadListImage(tempList,AppStoreActivity.MSG_FINISH_ONE_CLASS); return tempList; }
/** * 根据分类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; }
/** * 获取某个应用的详情 * * @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; }
/** * 获得应用推荐榜信息,系统启动后默认的 * * @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; }