Exemplo n.º 1
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) + ""));
  }
Exemplo n.º 2
0
  private void initData() {
    Session.getInstance()
        .getSetupDevice()
        .getCommandDataByImeiAndType(
            DeviceRestActivity.this,
            CmdType.CL.getType(),
            new BctClientCallback() {
              @Override
              public void onStart() {
                WizardAlertDialog.getInstance()
                    .showProgressDialog(R.string.get_data, DeviceRestActivity.this);
              }

              @Override
              public void onFinish() {
                WizardAlertDialog.getInstance().closeProgressDialog();
              }

              @Override
              public void onSuccess(ResponseData obj) {
                if (obj.getRetcode() == 1) {
                  // init data
                  String type = JSONHelper.getString(obj.getBody(), "type");
                  if (CmdType.CL.getType().equals(type)) {
                    //						Toast.makeText(DeviceRestActivity.this,
                    // JSONHelper.getString(obj.getBody(), "content"), Toast.LENGTH_SHORT).show();
                    String cmdCont = JSONHelper.getString(obj.getBody(), "content");
                    initView(cmdCont);
                  }
                } else {
                  Toast.makeText(DeviceRestActivity.this, obj.getMsg(), Toast.LENGTH_SHORT).show();
                }
              }

              @Override
              public void onFailure(String message) {
                Toast.makeText(DeviceRestActivity.this, message, Toast.LENGTH_SHORT).show();
              }
            });
  }
Exemplo n.º 3
0
  /**
   * 发送指令
   *
   * @param content 终端IMEI号
   */
  private void sendCommand(final String content) {
    CommService.get()
        .sendCommand(
            DeviceRestActivity.this,
            Session.getInstance().getSetupDevice().getImei(),
            CmdType.CL.getType(),
            content,
            new BctClientCallback() {
              @Override
              public void onStart() {
                WizardAlertDialog.getInstance().showProgressDialog("", DeviceRestActivity.this);
              }

              @Override
              public void onFinish() {
                WizardAlertDialog.getInstance().closeProgressDialog();
                // CustomProgressDialog.getInstance(getActivity()).closeProgressDialog();
              }

              @Override
              public void onSuccess(ResponseData obj) {
                if (obj.getRetcode() == 1) {
                  Toast.makeText(
                          DeviceRestActivity.this,
                          R.string.setup_rest_time_success_later,
                          Toast.LENGTH_SHORT)
                      .show();
                  finish();
                } else {
                  Toast.makeText(DeviceRestActivity.this, obj.getMsg(), Toast.LENGTH_SHORT).show();
                }
              }

              @Override
              public void onFailure(String message) {
                Toast.makeText(DeviceRestActivity.this, message, Toast.LENGTH_SHORT).show();
              }
            });
  }