コード例 #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 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);
  }