Exemplo n.º 1
0
  private void updateCurrentBgInfoCommon(TextView notificationText) {
    if (alreadyDisplayedBgInfoCommon) return; // with bluetooth and wifi, skip second time
    alreadyDisplayedBgInfoCommon = true;

    final boolean isSensorActive = Sensor.isActive();
    if (!isSensorActive) {
      notificationText.setText("Now start your sensor");
      return;
    }

    final long now = System.currentTimeMillis();
    if (Sensor.currentSensor().started_at + 60000 * 60 * 2 >= now) {
      double waitTime = (Sensor.currentSensor().started_at + 60000 * 60 * 2 - now) / 60000.0;
      notificationText.setText(
          "Please wait while sensor warms up! (" + String.format("%.2f", waitTime) + " minutes)");
      return;
    }

    if (BgReading.latest(2).size() > 1) {
      List<Calibration> calibrations = Calibration.latest(2);
      if (calibrations.size() > 1) {
        if (calibrations.get(0).possible_bad != null
            && calibrations.get(0).possible_bad == true
            && calibrations.get(1).possible_bad != null
            && calibrations.get(1).possible_bad != true) {
          notificationText.setText(
              "Possible bad calibration slope, please have a glass of water, wash hands, then recalibrate in a few!");
        }
        displayCurrentInfo();
      } else {
        notificationText.setText("Please enter two calibrations to get started!");
      }
    } else {
      if (BgReading.latestUnCalculated(2).size() < 2) {
        notificationText.setText("Please wait, need 2 readings from transmitter first.");
      } else {
        List<Calibration> calibrations = Calibration.latest(2);
        if (calibrations.size() < 2) {
          notificationText.setText("Please enter two calibrations to get started!");
        }
      }
    }
  }
 public BgGraphBuilder(Context context, long start, long end, int numValues) {
   end_time = end;
   start_time = start;
   bgReadings = BgReading.latestForGraph(numValues, start, end);
   calibrations = Calibration.latestForGraph(numValues, start, end);
   this.context = context;
   this.prefs = PreferenceManager.getDefaultSharedPreferences(context);
   this.highMark = Double.parseDouble(prefs.getString("highValue", "170"));
   this.lowMark = Double.parseDouble(prefs.getString("lowValue", "70"));
   this.doMgdl = (prefs.getString("units", "mgdl").equals("mgdl"));
   defaultMinY = unitized(40);
   defaultMaxY = unitized(250);
   pointSize = isXLargeTablet(context) ? 5 : 3;
   axisTextSize = isXLargeTablet(context) ? 20 : Axis.DEFAULT_TEXT_SIZE_SP;
   previewAxisTextSize = isXLargeTablet(context) ? 12 : 5;
   hoursPreviewStep = isXLargeTablet(context) ? 2 : 1;
 }