예제 #1
0
  private void initNav() {
    // 导航 begin
    mNavEListView = (ExpandableListView) findViewById(R.id.nav_elv);
    superAdapter = new SuperTreeViewAdapter(this, stvClickEvent);
    superAdapter.setHeight(navHeight);
    ArrayList<TreeVo> tlist = new ArrayList<TreeVo>();

    SharedPreferences settings = getSharedPreferences(Def.PREFS_NAME, 0);
    String njson = settings.getString(Def.SP_NAV_NAME, "");
    try {
      if (njson == null || "".equals(njson)) {
        new DataAsyncTask(this, false).execute("2");
      }
      if (njson == null || "".equals(njson)) {
        new DataAsyncTask(this, false).execute("2");
      }
      JSONArray jArr = new JSONArray(njson);
      tlist = SubjectDao.getArrayToTree(jArr);
    } catch (Exception e) {
      e.printStackTrace();
    }
    //
    List<SuperTreeViewAdapter.SuperTreeNode> superTreeNode = superAdapter.GetTreeNode();

    if (tlist != null && tlist.size() > 0) {
      for (int i = 0; i < tlist.size(); i++) {
        if (tlist.get(i).getParentid() == null || tlist.get(i).getParentid().equals("0")) {
          SuperTreeViewAdapter.SuperTreeNode superNode = new SuperTreeViewAdapter.SuperTreeNode();
          superNode.parent = tlist.get(i);
          for (int j = 0; j < tlist.size(); j++) {
            if (tlist.get(i).getTreeId().equals(tlist.get(j).getParentid())) {
              TreeViewAdapter.TreeNode node = new TreeViewAdapter.TreeNode();
              node.parent = tlist.get(j);
              for (int k = 0; k < tlist.size(); k++) {
                if (tlist.get(j).getTreeId().equals(tlist.get(k).getParentid())) {
                  node.childs.add(tlist.get(k));
                }
              }
              superNode.childs.add(node);
            }
          }
          superTreeNode.add(superNode);
        }
      }
    }
    superAdapter.UpdateTreeNode(superTreeNode);
    mNavEListView.setAdapter(superAdapter);
    mNavEListView.setOnGroupExpandListener(
        new OnGroupExpandListener() {
          @Override
          public void onGroupExpand(int arg0) {
            for (int i = 0; i < superAdapter.getGroupCount(); i++) {
              if (arg0 != i) {
                mNavEListView.collapseGroup(i);
              }
            }
          }
        });
    // 导航 end
  }
예제 #2
0
    @Override
    protected List<SubjectVo> doInBackground(Void... params) {
      try {
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("orderby", mType);
        param.put("typeid", typeid);
        param.put("page", prlistView.getPage());
        param.put("size", Def.M_LIST_SIZE);
        if (userInfo != null) {
          param.put("memberid", userInfo.getMemberid());
        }
        List<SubjectVo> tlist = SubjectDao.getSubjectList(param);

        if (prlistView.getPage() > 0) {
          if (tlist != null) {
            for (SubjectVo tv : tlist) {
              data.add(tv);
            }
          }
        } else {
          data = tlist;
        }
        if (tlist.size() < Def.M_LIST_SIZE) {
          isFoot = false;
        } else {
          if (tlist != null && tlist.size() > 0) isFoot = true;
          else isFoot = false;
        }
      } catch (EuException ex) {
        ex.printStackTrace();
        exType = 1;
        erMsg = ex.getMessage();
        data = null;
        isFoot = false;
        LogUtil.d("XB", "" + ex.getMessage());
      } catch (Exception e) {
        e.printStackTrace();
        data = null;
        isFoot = false;
      }
      return data;
    }