Esempio n. 1
0
 private List<OrgBean> initDatas() {
   List<OrgBean> mDatas2 = new ArrayList<OrgBean>();
   main.idOfTreeList = 1;
   // initDatas
   OrgBean bean2 = new OrgBean(main.idOfTreeList, 0, "最近");
   main.idOfTreeList++;
   mDatas2.add(bean2);
   bean2 = new OrgBean(main.idOfTreeList, 0, "过去7天");
   main.idOfTreeList++;
   mDatas2.add(bean2);
   bean2 = new OrgBean(main.idOfTreeList, 0, "一个月内");
   main.idOfTreeList++;
   mDatas2.add(bean2);
   bean2 = new OrgBean(main.idOfTreeList, 0, "往前");
   main.idOfTreeList++;
   mDatas2.add(bean2);
   return mDatas2;
 }
Esempio n. 2
0
  @Override
  public void run() {
    // TODO Auto-generated method stub

    if (link()) // 如果连接成功 那么就更新信息
    {
      handler.post(
          new Runnable() {

            @Override
            public void run() {
              // TODO Auto-generated method stub
              Toast.makeText(main, "连接成功", Toast.LENGTH_SHORT).show();
            }
          });
      // 如果连接成功了 将状态设为2
      main.setflagForWifiBluetooth(2); // 设为wifi模式
      try {
        initialSocket();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

    } else {
      handler.post(
          new Runnable() {

            @Override
            public void run() {
              // TODO Auto-generated method stub
              Toast.makeText(main, "连接超时,请检查网络连接", Toast.LENGTH_SHORT).show();
              main.setflagForWifiBluetooth(0); // 设回默认状态
            }
          });
    }
  }
Esempio n. 3
0
  private boolean setList(String msg) {
    // 将得到的String进行分解
    Vector<String[]> records = new Vector<String[]>();
    String[] recordsTemp;
    records = new Vector<String[]>(); // 回0
    recordsTemp = msg.split("@");
    for (int i = 0; i < recordsTemp.length; i++) {
      records.add(recordsTemp[i].split("&"));
    }
    Log.i("AL", "NetThread SetList 附值完毕");
    String[] str = records.get(0);
    if (!str[0].equals("Records")) // 如果不是用于记录的信息则退出
    {
      return false;
    }
    main.mDatas2 = initDatas();
    for (String[] strs : records) {
      if (strs[0] == "" || strs == null || !strs[0].equals("Records")) {
        Log.i("AL", "NetThread SetList 条件不满足而退出");
        Log.i("AL", strs[0]);
        return false;
      }
      int year = Integer.parseInt(strs[2].substring(0, 4));
      int month = Integer.parseInt(strs[2].substring(4, 6));
      int day = Integer.parseInt(strs[2].substring(6, 8));
      int hour = Integer.parseInt(strs[2].substring(8, 10));
      Calendar calendar = Calendar.getInstance();
      int yearNow = calendar.get(Calendar.YEAR);
      int monthNow = calendar.get(Calendar.MONTH) + 1;
      int dayNow = calendar.get(Calendar.DAY_OF_MONTH);
      int hourNow = calendar.get(Calendar.HOUR_OF_DAY);
      // 1最近 2一星期 3一个月 4往前
      int time = (year - 2000) * 365 + month * 30 + day;
      int timeNow = (yearNow - 2000) * 365 + monthNow * 30 + dayNow;
      if (timeNow - time <= 2) {
        OrgBean bean2 = new OrgBean(main.idOfTreeList, 1, strs[1]);
        main.idOfTreeList++;
        main.mDatas2.add(bean2);
        Log.i("AL", "NetThread SetList 最近项加入");
        Log.i(
            "AL",
            "year: "
                + year
                + " month: "
                + month
                + " day: "
                + day
                + " hour: "
                + hour
                + " time"
                + time);
        Log.i(
            "AL",
            "yearNow: "
                + yearNow
                + " monthNow: "
                + monthNow
                + " dayNow: "
                + dayNow
                + " hourNow: "
                + hourNow
                + " timeNow"
                + timeNow);

      } else if (timeNow - time <= 7) {
        OrgBean bean2 = new OrgBean(main.idOfTreeList, 2, strs[1]);
        main.idOfTreeList++;
        main.mDatas2.add(bean2);
        Log.i("AL", "NetThread SetList 星期项加入");
      } else if (timeNow - time <= 30) {
        OrgBean bean2 = new OrgBean(main.idOfTreeList, 3, strs[1]);
        main.idOfTreeList++;
        main.mDatas2.add(bean2);
        Log.i("AL", "NetThread SetList 月项加入");
      } else {
        OrgBean bean2 = new OrgBean(main.idOfTreeList, 4, strs[1]);
        main.idOfTreeList++;
        main.mDatas2.add(bean2);
        Log.i("AL", "NetThread SetList 往前项加入");
      }
    }
    try {
      main.mAdapter = new SimpleTreeListViewAdapter<OrgBean>(main.mTree, main, main.mDatas2, 0);
      main.mTree.setAdapter(main.mAdapter);

    } catch (IllegalAccessException e) {
      e.printStackTrace();
    }
    return true;
  }