예제 #1
0
  @Override
  public View getView() {

    View view;
    if (mBloodOxygen != null) {
      LayoutInflater inflater = LayoutInflater.from(mContext);
      view = inflater.inflate(layout.dialog_share_item_single, null);
      ImageView ivResultIcon = (ImageView) view.findViewById(id.iv_result_icon);
      TextView tvTitle = (TextView) view.findViewById(id.tv_title);
      TextView tvUnit1 = (TextView) view.findViewById(id.tv_unit_1);
      TextView tvValue1 = (TextView) view.findViewById(id.tv_value_1);
      TextView tvUnitEn1 = (TextView) view.findViewById(id.tv_unit_en_1);
      TextView tvUnit2 = (TextView) view.findViewById(id.tv_unit_2);
      TextView tvValue2 = (TextView) view.findViewById(id.tv_value_2);
      TextView tvUnitEn2 = (TextView) view.findViewById(id.tv_unit_en_2);
      TextView tvMeasureTime = (TextView) view.findViewById(id.tv_measure_time);

      tvTitle.setText(R.string.blood_oxygen);

      tvUnit1.setText(R.string.blood_oxygen_saturation);
      tvValue1.setText("" + mBloodOxygen.getOxygen().intValue());
      tvUnitEn1.setText("%");

      tvUnit2.setText(R.string.heart_rate);
      tvValue2.setText("" + mBloodOxygen.getRate().intValue());
      tvUnitEn2.setText("bpm");

      Date mDate =
          TimeUtils.getDate(
              mBloodOxygen.getMeasureTime().longValue() * 1000L, TimeUtils.YYYYMMDD_HHMMSS);
      String dateFormat = TimeUtils.getTime(mDate.getTime(), TimeUtils.YYYY_MM_DD_HH_MM_SS);
      // String dateFormat =
      // TimeUtils.getTime(mBloodOxygen.getMeasureTime().longValue() *
      // 1000, TimeUtils.YY_MM_DD);
      tvMeasureTime.setText(dateFormat);

      switch (mBloodOxygen.getAbnormal()) {
        case BloodOxygen.OXYGEN_STATE_LOW:
          ivResultIcon.setImageResource(R.drawable.group_chat_testresult_hypoxemia);
          break;
        case BloodOxygen.OXYGEN_STATE_IDEAL:
          ivResultIcon.setImageResource(R.drawable.group_chat_testresult_normal);
          break;
        case BloodOxygen.OXYGEN_STATE_MISSING:
          ivResultIcon.setImageResource(R.drawable.group_chat_testresult_lossofoxygensaturation);
          break;
        default:
          ivResultIcon.setImageResource(R.drawable.group_chat_testresult_normal);
      }
    } else {
      TextView tv = new TextView(mContext);
      tv.setText(errorAlert);
      view = tv;
    }
    return view;
  }
예제 #2
0
  @Override
  public void doShareWithUrl(TaskHost taskHost) {

    String accessToken = AccountProxy.getInstance().getCurrentAccount().getAccessToken();
    String type = MCloudDevice.OXY.getTag();

    // XXX 临时方案,解决分享中出现41904错误,待缓存这块重构
    String uid = mBloodOxygen.getMeasureUID();

    BloodOxygenModule oxyModule =
        (BloodOxygenModule)
            CloudMeasureModuleCentreRoot.getInstance()
                .create(
                    AccountProxy.getInstance().getCurrentAccount(),
                    BloodOxygenModule.class.getCanonicalName(),
                    true);

    BloodOxygen tmpOxygen = oxyModule.getCacheController().getMeasureBloodOxygen(uid);

    Integer recordID = tmpOxygen.getRecordID();
    GroupHelper.doShareUrlRecordTask(context, accessToken, type, recordID, null, null, taskHost);
  }
예제 #3
0
  @Override
  public void doSendShareMessage(TaskHost taskHost, IChat iChat, String shareURL) {

    JSONObject jo = new JSONObject();
    try {
      jo.put("type", MCloudDevice.OXY.getTag());
      jo.put("value1", mBloodOxygen.getOxygen().toString());
      jo.put("value2", mBloodOxygen.getRate().toString());
      jo.put("time", mBloodOxygen.getMeasureTime().longValue());
      jo.put("state", mBloodOxygen.getAbnormal());
      jo.put("url", shareURL);
      jo.put("report_type", Message.TYPE_RECORD);
    } catch (JSONException e) {
      e.printStackTrace();
    }
    MessageController.doPostItemFromServer(
        context,
        AccountProxy.getInstance().getCurrentAccount(),
        iChat.getIChatInterlocutorIdServer(),
        jo.toString(),
        Message.TYPE_RECORD,
        taskHost);
  }
예제 #4
0
  private static BloodOxygen parse(JSONObject jo, BloodOxygen bo) {
    try {
      if (jo.has("recordid") && !jo.isNull("recordid")) {
        bo.setRecordID(jo.getInt("recordid"));
      }
      if (jo.has("measureuid") && !jo.isNull("measureuid")) {

        String uid = jo.getString("measureuid");
        bo.setMeasureUID(uid);
      }
      if (jo.has("source") && !jo.isNull("source")) {
        bo.setSource(jo.getString("source"));
      }
      if (jo.has("readme") && !jo.isNull("readme")) {
        bo.setReadme(jo.getString("readme"));
      }
      if (jo.has("x") && !jo.isNull("x")) {
        bo.setX(jo.getDouble("x"));
      }
      if (jo.has("y") && !jo.isNull("y")) {
        bo.setY(jo.getDouble("y"));
      }
      if (jo.has("z") && !jo.isNull("z")) {
        bo.setZ(jo.getDouble("z"));
      }
      if (jo.has("state") && !jo.isNull("state")) {
        bo.setAbnormal(jo.getInt("state"));
      }
      if (jo.has("uptime") && !jo.isNull("uptime")) {
        bo.setUptime(jo.getLong("uptime"));
      }
      if (jo.has("value1") && !jo.isNull("value1")) {
        bo.setOxygen(jo.getInt("value1"));
      }
      if (jo.has("value2") && !jo.isNull("value2")) {
        bo.setRate(jo.getInt("value2"));
      }
      bo.setStateFlag(STATE_SYNCHRONIZED);
    } catch (JSONException e) {
      e.printStackTrace();
    }
    return bo;
  }
예제 #5
0
  public static BloodOxygen createBloodOxygen(JSONObject jo, Account account) {

    BloodOxygen bo = new BloodOxygen();
    bo.setBelongAccount(account);
    return parse(jo, bo);
  }