Пример #1
0
  @Override
  public void onClick(View view) {
    switch (view.getId()) {
      case R.id.backBtn:
        DeviceRestActivity.this.finish();
        break;
      case R.id.button1:
        try {
          String startTime = startTimeTV.getText().toString();
          String endTime = endTimeTV.getText().toString();
          StringBuffer bufferOne = new StringBuffer();
          StringBuffer bufferTwo = new StringBuffer();
          if (checkTVOne1.isChecked()) {
            bufferOne.append("1");
          } else {
            bufferOne.append("0");
          }
          if (checkTVOne2.isChecked()) {
            bufferOne.append("2");
          } else {
            bufferOne.append("0");
          }
          if (checkTVOne3.isChecked()) {
            bufferOne.append("3");
          } else {
            bufferOne.append("0");
          }
          if (checkTVOne4.isChecked()) {
            bufferOne.append("4");
          } else {
            bufferOne.append("0");
          }
          if (checkTVOne5.isChecked()) {
            bufferOne.append("5");
          } else {
            bufferOne.append("0");
          }
          if (checkTVOne6.isChecked()) {
            bufferOne.append("6");
          } else {
            bufferOne.append("0");
          }
          if (checkTVOne7.isChecked()) {
            bufferOne.append("7");
          } else {
            bufferOne.append("0");
          }

          if (checkTV1.isChecked()) {
            bufferTwo.append("1");
          } else {
            bufferTwo.append("0");
          }
          if (checkTV2.isChecked()) {
            bufferTwo.append("2");
          } else {
            bufferTwo.append("0");
          }
          if (checkTV3.isChecked()) {
            bufferTwo.append("3");
          } else {
            bufferTwo.append("0");
          }
          if (checkTV4.isChecked()) {
            bufferTwo.append("4");
          } else {
            bufferTwo.append("0");
          }
          if (checkTV5.isChecked()) {
            bufferTwo.append("5");
          } else {
            bufferTwo.append("0");
          }
          if (checkTV6.isChecked()) {
            bufferTwo.append("6");
          } else {
            bufferTwo.append("0");
          }
          if (checkTV7.isChecked()) {
            bufferTwo.append("7");
          } else {
            bufferTwo.append("0");
          }
          String content =
              String.format(
                  "%s-%s,%s,%s-%s,%s",
                  startTimeTV.getText().toString(),
                  endTimeTV.getText().toString(),
                  bufferOne,
                  startTimeTV1.getText().toString(),
                  endTimeTV1.getText().toString(),
                  bufferTwo);
          // String content =
          // startTime+"-"+endTime+","+startTime+"-"+endTime+","+bufferTwo.toString();
          content = content.replace(":", "");
          if (Session.getInstance().getDevice() != null) {
            sendCommand(content);
          }
          //					addFence(object);
        } catch (Exception e) {
          e.printStackTrace();
        }
        break;
      case R.id.checkTV1:
        if (checkTV1.isChecked()) {
          checkTV1.setChecked(false);
        } else {
          checkTV1.setChecked(true);
        }
        break;
      case R.id.checkTV2:
        if (checkTV2.isChecked()) {
          checkTV2.setChecked(false);
        } else {
          checkTV2.setChecked(true);
        }
        break;
      case R.id.checkTV3:
        if (checkTV3.isChecked()) {
          checkTV3.setChecked(false);
        } else {
          checkTV3.setChecked(true);
        }
        break;
      case R.id.checkTV4:
        if (checkTV4.isChecked()) {
          checkTV4.setChecked(false);
        } else {
          checkTV4.setChecked(true);
        }
        break;
      case R.id.checkTV5:
        if (checkTV5.isChecked()) {
          checkTV5.setChecked(false);
        } else {
          checkTV5.setChecked(true);
        }
        break;
      case R.id.checkTV6:
        if (checkTV6.isChecked()) {
          checkTV6.setChecked(false);
        } else {
          checkTV6.setChecked(true);
        }
        break;
      case R.id.checkTV7:
        if (checkTV7.isChecked()) {
          checkTV7.setChecked(false);
        } else {
          checkTV7.setChecked(true);
        }
        break;
      case R.id.checkTV_all:
        if (checkTVAll.isChecked()) {
          checkTV1.setChecked(false);
          checkTV2.setChecked(false);
          checkTV3.setChecked(false);
          checkTV4.setChecked(false);
          checkTV5.setChecked(false);
          checkTV6.setChecked(false);
          checkTV7.setChecked(false);
          checkTVAll.setChecked(false);
        } else {
          checkTV1.setChecked(true);
          checkTV2.setChecked(true);
          checkTV3.setChecked(true);
          checkTV4.setChecked(true);
          checkTV5.setChecked(true);
          checkTV6.setChecked(true);
          checkTV7.setChecked(true);
          checkTVAll.setChecked(true);
        }
        break;

      case R.id.checkTV_one_1:
        if (checkTVOne1.isChecked()) {
          checkTVOne1.setChecked(false);
        } else {
          checkTVOne1.setChecked(true);
        }
        break;
      case R.id.checkTV_one_2:
        if (checkTVOne2.isChecked()) {
          checkTVOne2.setChecked(false);
        } else {
          checkTVOne2.setChecked(true);
        }
        break;
      case R.id.checkTV_one_3:
        if (checkTVOne3.isChecked()) {
          checkTVOne3.setChecked(false);
        } else {
          checkTVOne3.setChecked(true);
        }
        break;
      case R.id.checkTV_one_4:
        if (checkTVOne4.isChecked()) {
          checkTVOne4.setChecked(false);
        } else {
          checkTVOne4.setChecked(true);
        }
        break;
      case R.id.checkTV_one_5:
        if (checkTVOne5.isChecked()) {
          checkTVOne5.setChecked(false);
        } else {
          checkTVOne5.setChecked(true);
        }
        break;
      case R.id.checkTV_one_6:
        if (checkTVOne6.isChecked()) {
          checkTVOne6.setChecked(false);
        } else {
          checkTVOne6.setChecked(true);
        }
        break;
      case R.id.checkTV_one_7:
        if (checkTVOne7.isChecked()) {
          checkTVOne7.setChecked(false);
        } else {
          checkTVOne7.setChecked(true);
        }
        break;
      case R.id.checkTV_one_all:
        if (checkTVOneAll.isChecked()) {
          checkTVOne1.setChecked(false);
          checkTVOne2.setChecked(false);
          checkTVOne3.setChecked(false);
          checkTVOne4.setChecked(false);
          checkTVOne5.setChecked(false);
          checkTVOne6.setChecked(false);
          checkTVOne7.setChecked(false);
          checkTVOneAll.setChecked(false);
        } else {
          checkTVOne1.setChecked(true);
          checkTVOne2.setChecked(true);
          checkTVOne3.setChecked(true);
          checkTVOne4.setChecked(true);
          checkTVOne5.setChecked(true);
          checkTVOne6.setChecked(true);
          checkTVOne7.setChecked(true);
          checkTVOneAll.setChecked(true);
        }
        break;

      case R.id.startTimeTV:
        showTimeDialog(startTimeTV.getText().toString(), (TextView) view);
        break;
      case R.id.endTimeTV:
        showTimeDialog(endTimeTV.getText().toString(), (TextView) view);
        break;
      case R.id.startTimeTV2:
        showTimeDialog(startTimeTV1.getText().toString(), (TextView) view);
        break;
      case R.id.endTimeTV2:
        showTimeDialog(endTimeTV1.getText().toString(), (TextView) view);
        break;
    }
  }
Пример #2
0
  private void initView(String cont) {
    if (CommUtil.isBlank(cont)) {
      return;
    }
    String[] conts = cont.split(" *, *");
    if (conts.length != 5) {
      Log.e(Constants.TAG, "指令长度不为10节,长度不对,指令内容:" + cont);
      return;
    }
    String[] time1 = formatTimeStr(conts[1].replaceAll(CmdType.CL.getType() + "=", ""));
    String[] time2 = formatTimeStr(conts[3]);
    startTimeTV.setText(time1[0]);
    endTimeTV.setText(time1[1]);
    startTimeTV1.setText(time2[0]);
    endTimeTV1.setText(time2[1]);

    int j = 2;
    checkTVOne1.setChecked(!"0".equals(conts[j].charAt(0) + ""));
    checkTVOne2.setChecked(!"0".equals(conts[j].charAt(1) + ""));
    checkTVOne3.setChecked(!"0".equals(conts[j].charAt(2) + ""));
    checkTVOne4.setChecked(!"0".equals(conts[j].charAt(3) + ""));
    checkTVOne5.setChecked(!"0".equals(conts[j].charAt(4) + ""));
    checkTVOne6.setChecked(!"0".equals(conts[j].charAt(5) + ""));
    checkTVOne7.setChecked(!"0".equals(conts[j].charAt(6) + ""));

    int i = 4;
    checkTV1.setChecked(!"0".equals(conts[i].charAt(0) + ""));
    checkTV2.setChecked(!"0".equals(conts[i].charAt(1) + ""));
    checkTV3.setChecked(!"0".equals(conts[i].charAt(2) + ""));
    checkTV4.setChecked(!"0".equals(conts[i].charAt(3) + ""));
    checkTV5.setChecked(!"0".equals(conts[i].charAt(4) + ""));
    checkTV6.setChecked(!"0".equals(conts[i].charAt(5) + ""));
    checkTV7.setChecked(!"0".equals(conts[i].charAt(6) + ""));
  }