コード例 #1
0
  public static MyepePrizeBean parse(JSONObject jsonEvent) {

    MyepePrizeBean prizebean = new MyepePrizeBean();
    try {
      prizebean.setType(jsonEvent.getString("type"));
      prizebean.setContent(jsonEvent.getString("content"));
      prizebean.setTitle(jsonEvent.getString("title"));
      prizebean.setStartTime(jsonEvent.optString("startTime"));
      prizebean.setStatus(jsonEvent.getString("status"));
      prizebean.setEventId(jsonEvent.getString("eventId"));

      String eventUrl = jsonEvent.optString("eventUrl");
      if ((eventUrl == null || eventUrl.equals("")) && prizebean.getEventId() != null) {
        eventUrl = "mktgEventController.view?method=getevent&eventId=" + prizebean.getEventId();
      }
      prizebean.setEventUrl(eventUrl);

      prizebean.setCreateOrgid(jsonEvent.getString("createOrgId"));
      prizebean.setCreateOrgName(jsonEvent.getString("createOrgName"));
      prizebean.setIntroducerBonus(jsonEvent.getString("introducerBonus"));
      prizebean.setReferralBonus(jsonEvent.getString("referralBonus"));
      prizebean.setPerAwardNum(jsonEvent.getString("perAwardNum"));

      String path = jsonEvent.optString("path");
      String thumbPath = jsonEvent.optString("thumbPath");
      if (!jsonEvent.isNull("mktgPicList")) {
        List<Photo> mktgPicList = PhotoListWrapper.parse(jsonEvent.getJSONArray("mktgPicList"));
        if (mktgPicList != null && mktgPicList.size() > 0) {
          Photo pho = mktgPicList.get(0);
          path = pho.getPath() + pho.getSaveName();
          thumbPath = pho.getThumbPath() + pho.getThumbSaveName();
        }
      }

      if (path != null && !path.equals("") && !path.startsWith(URLs.PROCOTOL)) {
        path = URLs.URL_IMG_API_HOST + path;
      }
      if (thumbPath != null && !thumbPath.equals("") && !thumbPath.startsWith(URLs.PROCOTOL)) {
        thumbPath = URLs.URL_IMG_API_HOST + thumbPath;
      }
      prizebean.setEvtPicPath(path);
      prizebean.setEvtThumbPicPath(thumbPath);

    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    } catch (AppException e) {
      e.printStackTrace();
    }
    return prizebean;
  }
コード例 #2
0
  public static List<FriendsCommentListBean> parse(JSONArray commentListJsonArray)
      throws JSONException {

    if (commentListJsonArray == null || commentListJsonArray.length() == 0) {
      return null;
    }

    List<FriendsCommentListBean> commentList = new ArrayList<FriendsCommentListBean>();
    for (int i = 0; i < commentListJsonArray.length(); i++) {
      JSONObject jsonObjectPic = commentListJsonArray.optJSONObject(i);
      FriendsCommentListBean friendsCommentListBean = new FriendsCommentListBean();
      friendsCommentListBean.setCommentId(jsonObjectPic.getString("commentId"));
      if (!jsonObjectPic.isNull("showUserName")) {
        friendsCommentListBean.setShowUserName(jsonObjectPic.getString("showUserName"));
      } else {
        friendsCommentListBean.setShowUserName(null);
      }
      if (!jsonObjectPic.isNull("userShortName")) {
        friendsCommentListBean.setUserShortName(jsonObjectPic.getString("userShortName"));
      } else {
        friendsCommentListBean.setUserShortName(null);
      }
      friendsCommentListBean.setUserPhoto(jsonObjectPic.getString("userPhoto"));
      if (!jsonObjectPic.isNull("userPhone")) {
        friendsCommentListBean.setUserPhone(jsonObjectPic.getString("userPhone"));
      } else {
        friendsCommentListBean.setUserPhone(null);
      }
      friendsCommentListBean.setIsAnonymous(jsonObjectPic.getString("isAnonymous"));
      friendsCommentListBean.setComDate(jsonObjectPic.getString("comDate"));
      friendsCommentListBean.setOrgName(jsonObjectPic.getString("orgName"));
      friendsCommentListBean.setCourName(jsonObjectPic.getString("courName"));
      if (!jsonObjectPic.isNull("courId")) {
        friendsCommentListBean.setCourId(jsonObjectPic.getString("courId"));
      } else {
        friendsCommentListBean.setCourId(null);
      }
      if (!jsonObjectPic.isNull("orgId")) {
        friendsCommentListBean.setOrgId(jsonObjectPic.getString("orgId"));
      } else {
        friendsCommentListBean.setOrgId(null);
      }
      if (!jsonObjectPic.isNull("helpfulName")) {
        friendsCommentListBean.setHelpfulName(jsonObjectPic.optString("helpfulName"));
      } else {
        friendsCommentListBean.setHelpfulName(null);
      }

      if (!jsonObjectPic.isNull("org")) {
        JSONObject orgObject = jsonObjectPic.getJSONObject("org");
        friendsCommentListBean.setLogoPath(orgObject.optString("logoPath"));
      }

      friendsCommentListBean.setRatingList(Rating.Helper.getCourseRatingFromJson(jsonObjectPic));
      friendsCommentListBean.setContent(jsonObjectPic.getString("content"));
      friendsCommentListBean.setHelpfulNum(jsonObjectPic.getString("helpfulNum"));
      friendsCommentListBean.setIsHelpful(jsonObjectPic.getString("isHelpful"));
      friendsCommentListBean.setDistance(jsonObjectPic.getString("distance"));
      friendsCommentListBean.setCurrenUserLike(false);
      friendsCommentListBean.setUserId(jsonObjectPic.getString("userId"));

      if (!jsonObjectPic.isNull("picList")) {
        try {
          friendsCommentListBean.setPicList(
              PhotoListWrapper.parse(jsonObjectPic.getJSONArray("picList")));
        } catch (AppException e) {
          e.printStackTrace();
        }
      }

      commentList.add(friendsCommentListBean);
    }

    return commentList;
  }