Ejemplo n.º 1
0
  private void JsonResult(String con) {
    // TODO Auto-generated method stub
    try {
      JSONObject all = new JSONObject(con);
      Log.d(TAG + "JsonResult", con);
      Boolean result = all.optBoolean("result");
      int resultId = all.optInt("resultId");
      String resultMSG = all.optString("resultMSG");
      if (mToastLoding != null && mToastLoding.isShowing()) {
        mToastLoding.cancel();
      }
      if (result) {
        JSONObject data = all.optJSONObject("data");
        JSONArray memo = data.optJSONArray("memos");
        if (null != memo) {
          for (int i = 0; i < memo.length(); i++) {
            Log.d(TAG + "memo", i + "");
            JSONObject item = memo.optJSONObject(i);
            ListItem mlistitem = new ListItem();
            mlistitem.content = item.optString("content");
            mlistitem.id = item.optInt("id");
            mlistitem.isalarmclock = item.optInt("ifAlarm");
            mlistitem.type = item.optInt("type");
            mlistitem.date = item.optString("taskTime");
            mlistitem.bgcolor = -1;
            mlistitem.isLocal = false;
            mlistitem.FormPhone = item.optString("phoneNumber");
            memolist.add(mlistitem);
          }
        }
        mMemoListViewAdapter.notifyDataSetChanged();
        StepChildComparator comparator = new StepChildComparator();
        Collections.sort(memolist, comparator);
      } else {
        APPConfigure.CheckToken(this, resultId, resultMSG);
      }
      all = null;

    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
  private static void handleData() {
    Log.d(Tag + "handleData", "handleData");
    HistorygroupList = new ArrayList<Group>();
    HistorygchildList = new ArrayList<List<ListItem>>();
    NowgroupList = new ArrayList<Group>();
    NowchildList = new ArrayList<List<ListItem>>();
    if (ServerMemoList != null && ServerMemoList.size() > 0) {
      for (ServerMemo mServerMemo : ServerMemoList) {
        SimpleDateFormat format = new SimpleDateFormat(DateTimeFormatPattern);
        Log.d(Tag + "handleData", "handleData1");
        try {
          Date date1 = format.parse(mServerMemo.taskDate);
          Date date2 = format.parse(MyApplication.getMyApplication().mNowTime.NowDate);
          Log.d(Tag + "handleData", "handleData2");
          if (date1.getTime() < date2.getTime()) {
            if (ishisaddGroup(mServerMemo.taskDate)) {
              Group hisgroup = new Group();
              hisgroup.setTitle(mServerMemo.taskDate);
              HistorygroupList.add(hisgroup);
            }
          } else {
            if (isaddGroup(mServerMemo.taskDate)) {
              Group group = new Group();
              group.setTitle(mServerMemo.taskDate);
              NowgroupList.add(group);
            }
          }
        } catch (ParseException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          Log.d(Tag + "handleData", e.toString());
        }
      }
    }

    if (NowgroupList.size() > 0) {
      Log.d(Tag + "handleData", "handleData3");

      for (Group mgroup : NowgroupList) {
        List<ListItem> childTemp = new ArrayList<ListItem>();
        Log.d("MainActivity", "mgroup:" + mgroup.getTitle().toString());
        int id = 1010;
        for (ServerMemo mServerMemo : ServerMemoList) {
          if (mgroup.getTitle().equals(mServerMemo.taskDate)) {
            ListItem mlistitem = new ListItem();
            mlistitem.time = mServerMemo.taskTime;
            mlistitem.content = mServerMemo.content;
            mlistitem.id = Integer.parseInt(mServerMemo.id);
            mlistitem.isalarmclock = Integer.parseInt(mServerMemo.ifAlarm);
            mlistitem.type = Integer.parseInt(mServerMemo.type);
            mlistitem.date = mServerMemo.taskDate;
            mlistitem.bgcolor = -1;
            mlistitem.isLocal = false;
            mlistitem.FormPhone = mServerMemo.fromPhone;
            String[] date = mlistitem.date.trim().split("/");
            int year = 0;
            int mouth = 0;
            int day = 0;
            if (date != null && date.length == 3) {
              year = Integer.parseInt(date[0]);
              mouth = Integer.parseInt(date[1]);
              day = Integer.parseInt(date[2]);
            }
            String[] time = mlistitem.time.split(":");
            int hour = 0;
            int mini = 0;
            if (time != null && time.length == 2) {
              hour = Integer.parseInt(time[0]);
              mini = Integer.parseInt(time[1]);
            }
            if (mlistitem.isalarmclock == 1) {
              // setAlarmClock(id, year, mouth, day, hour, mini);
              id++;
            }

            childTemp.add(mlistitem);
          }
        }
        NowchildList.add(childTemp);
      }
    }

    if (HistorygroupList.size() > 0) {
      Log.d(Tag + "handleData", "handleData4");
      for (Group mgroup : HistorygroupList) {
        List<ListItem> hischildTemp = new ArrayList<ListItem>();
        for (ServerMemo mServerMemo : ServerMemoList) {
          if (mgroup.getTitle().equals(mServerMemo.taskDate)) {
            ListItem mlistitem = new ListItem();
            mlistitem.time = mServerMemo.taskTime;
            mlistitem.content = mServerMemo.content;
            mlistitem.id = Integer.parseInt(mServerMemo.id);
            mlistitem.isalarmclock = Integer.parseInt(mServerMemo.ifAlarm);
            mlistitem.type = Integer.parseInt(mServerMemo.type);
            mlistitem.date = mServerMemo.taskDate;
            mlistitem.bgcolor = -1;
            mlistitem.isLocal = false;
            mlistitem.FormPhone = mServerMemo.fromPhone;
            hischildTemp.add(mlistitem);
          }
        }
        HistorygchildList.add(hischildTemp);
      }
    }
  }