コード例 #1
0
 /**
  *
  *
  * <pre>解析封装职位分类列表  </pre>
  *
  * @param array JsonArray
  * @return
  * @throws JSONException
  */
 private static List<PositionClassify> parsePositionClassList(JSONArray array, String pcode)
     throws JSONException {
   List<PositionClassify> positionClasss = null;
   if (!StringUtils.isEmpty(array)) {
     int nn = array.size();
     PositionClassify positionClassify = null;
     positionClasss = new ArrayList<PositionClassify>(nn);
     for (int i = 0; i < nn; i++) {
       JSONObject jObject = array.getJSONObject(i);
       positionClassify = new PositionClassify();
       String code = jObject.getString("code");
       positionClassify.setCode(code);
       positionClassify.setPcode(pcode);
       positionClassify.setValue(jObject.getString("value"));
       boolean has = jObject.getIntValue("hassub") == 1;
       positionClassify.setHasSub(has);
       if (has) {
         JSONArray subArray = jObject.getJSONArray("sublist");
         if (!StringUtils.isEmpty(subArray)) {
           positionClassify.setSubList(parsePositionClassList(subArray, code));
         }
       }
       positionClasss.add(positionClassify);
       mapPositionClassifies.put(code, positionClassify);
     }
   }
   return positionClasss;
 }
コード例 #2
0
  /**
   * 加载子控件
   *
   * <pre>方法  </pre>
   *
   * @param area 地区
   */
  private void showSubAddressViews(PositionClassify positionClassify) {
    params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    params.height = 1;
    params.leftMargin = 40;
    if (null != linear_sub && linear_sub.getChildCount() > 0) {
      linear_sub.removeAllViews();
    }
    if (positionClassify != null) {
      List<PositionClassify> pList = positionClassify.getSubList();
      if (pList != null && pList.size() > 0) {
        if (!pList.get(0).getCode().equals(positionClassify.getCode())) {
          PositionClassify pp = new PositionClassify();
          pp.setCode(positionClassify.getCode());
          pp.setPcode(positionClassify.getPcode());
          pp.setHasSub(false);
          pp.setSubList(null);
          pp.setValue(positionClassify.getValue());
          pList.add(0, pp);
        }

        int nn = pList.size();
        for (int i = 0; i < nn; i++) {
          final PositionClassify p = pList.get(i);
          if (p != null) {
            final PositionClassItemView itemView = new PositionClassItemView(context);
            itemView.setPositionClassify(p);
            itemView.setOnItemClickListener(
                new View.OnClickListener() {

                  @Override
                  public void onClick(View v) {
                    if (p.isHasSub()) {

                    } else {
                      boolean flag = itemView.getCheckedStatus();
                      itemView.setCheckedStatus(!flag);
                      if (!flag) {
                        code = p.getCode();
                        value = p.getValue();
                        startIntent();
                        finish();
                      } else {
                        code = "";
                        value = "";
                      }
                    }
                  }
                });
            linear_sub.addView(itemView);
            if (i < nn - 1) {
              View line = LayoutInflater.from(context).inflate(R.layout.layout_line, null);
              linear_sub.addView(line, params);
            } else {
              params =
                  new LinearLayout.LayoutParams(
                      LinearLayout.LayoutParams.MATCH_PARENT,
                      LinearLayout.LayoutParams.WRAP_CONTENT);
              params.height = 1;
              params.leftMargin = 1;
              View line = LayoutInflater.from(context).inflate(R.layout.layout_line, null);
              linear_sub.addView(line, params);
            }
          }
        }
        scroll_page_sub.setAnimation(animation_in);
        scroll_page_sub.startAnimation(animation_in);
      }
    }
  }